-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Extend RTE output in Delivery API for better support for multi-site URL resolution #20846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Extend RTE output in Delivery API for better support for multi-site URL resolution #20846
Conversation
…ests to accomodate changes
|
Hi there @MiguelGuedelha, thank you for this contribution! 👍 While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:
Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution. If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request. Thanks, from your friendly Umbraco GitHub bot 🤖 🙂 |
AndyButland
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this contribution @MiguelGuedelha - and great job on ensuring the automated tests and providing clear justifications for why it's needed and how to verify. From my side, all looks good and I can confirm it does what is described.
I'm just going to run it by the team to see if there's anything I've overlooked in introducing these additional attributes in the output.
|
Thanks for this 🙌 really excellent work! Two things come to mind:
Does it sound reasonable to you? |
|
Hi @kjac Yeah, no real oppositions to whatever name changes/preferences might be best for consistency sake. Just mostly ported over the custom implementation of the parser that we've had implemented on a project before (damn you for ruining my plans of not needing to update our BFF api layer 😜) I'll make the changes possibly today if I can towards the end of it and push them up. |
…ontent-type -> link-type and use LinkType enum instead.
|
Have made the amends now @kjac Using nameof should easily allow the data contract to update automatically if LinkType ever evolves in the future for whatever reason without needing much reworks on the tests, etc |
|
Maybe this is a little inconsistent @kjac - in that for the content type, when we emit markup we have But with JSON output we have |
|
Should we instead simply remove the lines where the following is executed in the markup parser: link.Attributes["type"]?.Remove();So that type is simply left in the markup (which should be And not add any |
|
We can't remove anything that's already there - that would be a breaking change. I agree this is a little inconsistent. But the inconsistency is there already, between the URL picker output and URLs in the RTE output. One option is to add Let's look at the output for JSON rendered RTE content links (with this PR applied) versus URL picker content links: RTE content link {
"tag": "a",
"attributes": {
"target": "",
"router-slot": "disabled",
"title": "Root",
"type": "document",
"destination-id": "bea875f0-5bfd-48f6-87d9-6c4edc2050dd",
"route": {
"path": "/",
"queryString": null,
"startItem": {
"id": "bea875f0-5bfd-48f6-87d9-6c4edc2050dd",
"path": "root"
}
}
},
"elements": [
{
"text": "link",
"tag": "#text"
}
]
}URL picker content link {
"url": null,
"queryString": null,
"title": "Root",
"target": null,
"destinationId": "bea875f0-5bfd-48f6-87d9-6c4edc2050dd",
"destinationType": "page",
"route": {
"path": "/",
"queryString": null,
"startItem": {
"id": "bea875f0-5bfd-48f6-87d9-6c4edc2050dd",
"path": "root"
}
},
"linkType": "Content"
}They are actually quite similar - but with some key differences:
Now the real question is: Do we want to align these two closely? My gut feeling tells me that we should, but I have nothing concrete to pin it on. |
Answering to the reply to my feedbackSorry @kjac when I meant removing something that is there, it was removing a line of code, but removing that line of code would actually add data to the markup RTE rendering, not remove it. The RTE markup comes with a pre-populated attributed called "type" with has the "document"/"media" designation. The parser removes it, but if it didn't it would simply leave it in the RTE, essentially leading to a "new" field in the RTE output (hence non breaking as it's non-destructive, but rather additive). This would make the markup match the existing RTE JSON "type" output from the get go, instead of renaming it to "data-link-type" etc? JSON output alignment between RTE and URL pickerWhile aligning with the URL picker would be great for a more uniform and predictable data signature, I'd assuming aligning both the RTE markup vs RTE JSON would be first priority?
|
Prerequisites
If there's an existing issue for this PR then this fixes: #20845
Description
This makes the change for Umbraco v17, back-porting to a v16 (and v13) addition should be relatively straightforward if necessary after this merge, if accepted, as the change is non breaking.
Adds both the ID and type to the resolved link information in the Delivery API's RTE data (both JSON and Markup format)
This allows for much easier content/URL resolution in multi-site setups, both through the Delivery API (direct ID request) and also through custom built Link Resolution service/endpoints that might make use of the built in URL resolver tools, etc.
The distinction between media and document type simply allows users to, for example, only process document type links based on the discriminator field being present and
== documentI've fixed up the relevant unit tests I could find (both ones that failed from the change and also others that I reckoned would be better to check for the changes moving forward)
Replicating the feature is relatively straightforward: