🐛 fix(feed): fix "Visit website" link with skin config #286
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
We've observed an inconsistent behavior in the generation of Atom feed links, specifically regarding the construction of the
href
attribute for thevisit_the_site
link. The issue arises depending on theskin
variable's value in theconfig.toml
file. When theskin
variable is not set (i.e., left as an empty string ""), the XPath expression/atom:feed/atom:link[2]/@href
successfully retrieves the intended URL stored inconfig.base_url
. However, when theskin
variable is initialized with a value (e.g., "red"), the mentioned XPath expression fails to function as intended, leading to incorrecthref
values in the generated Atom feed.This behavior suggests that the insertion of an additional
<link>
element related to the skin configuration alters the document structure, affecting the index-based XPath selection.Changes
To address this variability and ensure a more stable and reliable generation of the
visit_the_site
link, irrespective of theskin
configuration or any other dynamic content that might affect the<link>
elements order, we propose to directly use the/atom:feed/@xml:base
XPath expression. This expression directly targets thexml:base
attribute of the<feed>
element, which consistently contains theconfig.base_url
value.This solution offers a more robust approach to determining the
href
attribute for thevisit_the_site link
, as it does not rely on the specific order or presence of<link>
elements within the Atom feed. It ensures that the link always correctly points to the base URL as defined in the site's configuration, regardless of any changes to other parts of the feed structure.The suggested change involves modifying the XSL transformation used to generate the Atom feed's HTML representation. Specifically, we will replace the
/atom:feed/atom:link[2]/@href
expression with/atom:feed/@xml:base
for setting thehref
attribute of thevisit_the_site link
.Type of change
Checklist
theme.toml
with a sane default for the featureconfig.toml
commentstheme.toml
comments