fix: RSS <head> autodiscovery link still has the #647 trailing-slash bug - #676
Open
LazyEngineer99 wants to merge 1 commit into
Open
fix: RSS <head> autodiscovery link still has the #647 trailing-slash bug#676LazyEngineer99 wants to merge 1 commit into
LazyEngineer99 wants to merge 1 commit into
Conversation
…rom satnaing#647 getRelativeLocaleUrl(locale, "rss.xml") appends a trailing slash, so the <head> alternate link points at /rss.xml/, which 404s (rss.xml.ts is a single-file route, not a folder route, so it never gets one). This is the same root cause satnaing#647/satnaing#649 already fixed for the homepage RSS button, just in a second call site that fix didn't touch. Rather than repeat the ad-hoc import.meta.env.BASE_URL construction from satnaing#649, this uses getAssetPath() (src/utils/withBase.ts) — the helper this same file already uses for the favicon and sitemap-index.xml links right below it, and the same site-root-relative rss.xml problem those solve.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
#647/#649 fixed the trailing-slash bug (
getRelativeLocaleUrl(locale, "rss.xml")→/rss.xml/→ 404) for the homepage RSS subscription button, but the same root cause has a second, untouched call site:src/layouts/Layout.astro's<head>RSS autodiscovery<link rel="alternate">. That link still points at/rss.xml/, which 404s sincerss.xml.tsis a single-file route and never gets a trailing slash.Found this while auditing a fork of this theme (a real production site) for an unrelated issue — verified against the live theme demo too: view-source on https://astro-paper.pages.dev/ still shows
href="https://astro-paper.pages.dev/rss.xml/"in<head>.Fix
Rather than reuse the
import.meta.env.BASE_URL.replace(...)construction from #649, this usesgetAssetPath()(src/utils/withBase.ts) — the helperLayout.astroalready imports and already uses for the favicon andsitemap-index.xmllinks a few lines below, solving the exact same "site-root-relative path, base-aware, not locale-prefixed" problem. Also drops the now-unusedgetRelativeLocaleUrlimport from this file.Verified:
pnpm run build+ grepped the builtdist/index.html,<head>now emitshref="https://astro-paper.pages.dev/rss.xml"(no trailing slash).pnpm run lintclean.Related Issue
Follow-up to #647 / #649 (second call site of the same bug, not covered by that fix).