Skip to content

feat(pat-inject): More metadata updates for history:record injections.#1280

Open
thet wants to merge 2 commits intomasterfrom
thet/inject/title-canonical-base
Open

feat(pat-inject): More metadata updates for history:record injections.#1280
thet wants to merge 2 commits intomasterfrom
thet/inject/title-canonical-base

Conversation

@thet
Copy link
Copy Markdown
Member

@thet thet commented Mar 23, 2026

When a URL manipulating injection with the history:record setting is done, we also want a bunch of other data be updated. That includes:

  • title
  • canonical link
  • base URL

We already had support for the title tag in the head section of the document. This PR adds support for <link rel="canonical" href="..." /> and <base href="..."> tags.

thet added 2 commits March 24, 2026 23:21
When the navigation URL changes on injections with the
``history:record`` setting, also update the canonical url
(``<link rel="canonical" href="URL"/>``) and the base url
(``<base>URL</base>``).

For the canonical and base tags, the logic is as follows:

- If present in source and target, update it in the target.
- If present in source but not in target, add it to the target.
- If present in target but not in source, remove it from the target.

It's better to have no canonical or base tag than an incorrect one.

For the title tag the logic is different, as the title is never removed
from the target. It's better to have any title than none.
Throw an event before the history is updated and the URL bar changes and
pass the original AJAX event along with it. This allows external code to
do some updates, like changing data-base-url and data-view-url on the
body, using the body information from the response for that. This is a
use-case in Plone and allows JavaScript code to get information on the
current context.
@thet thet force-pushed the thet/inject/title-canonical-base branch from dae949c to bc4c34f Compare March 24, 2026 22:22
@thet thet requested review from MrTango and petschki March 24, 2026 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant