Skip to content

fix: RSS <head> autodiscovery link still has the #647 trailing-slash bug - #676

Open
LazyEngineer99 wants to merge 1 commit into
satnaing:mainfrom
LazyEngineer99:fix/rss-head-link-trailing-slash
Open

fix: RSS <head> autodiscovery link still has the #647 trailing-slash bug#676
LazyEngineer99 wants to merge 1 commit into
satnaing:mainfrom
LazyEngineer99:fix/rss-head-link-trailing-slash

Conversation

@LazyEngineer99

Copy link
Copy Markdown
Contributor

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 since rss.xml.ts is 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 uses getAssetPath() (src/utils/withBase.ts) — the helper Layout.astro already imports and already uses for the favicon and sitemap-index.xml links a few lines below, solving the exact same "site-root-relative path, base-aware, not locale-prefixed" problem. Also drops the now-unused getRelativeLocaleUrl import from this file.

Verified: pnpm run build + grepped the built dist/index.html, <head> now emits href="https://astro-paper.pages.dev/rss.xml" (no trailing slash). pnpm run lint clean.

Related Issue

Follow-up to #647 / #649 (second call site of the same bug, not covered by that fix).

…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.
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