You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Plugins that build absolute URLs (sitemaps, canonical, hreflang) need to know the site's URL convention, but the plugin context (ctx.site) only carries name, url, and locale. So a plugin has to hardcode a trailing slash.
That's fine for Astro's default, but wrong for a site configured with trailingSlash: 'never'. It's especially a problem for headless setups, where the front-end serves bare URLs (like /blog/post) and the plugin's sitemap then advertises /blog/post/, which the site doesn't serve.
Proposal: expose Astro's trailingSlash on ctx.site, riding the same path the i18n config already uses (astro:config:setup to virtual:emdash/config to readSiteInfo to SiteInfo). It's optional and defaults to 'ignore' (Astro's default), so nothing changes for existing sites.
I hit this building the emdash-plugin-seo sitemap feed for a headless site. Happy to be told if there's a better approach or if it needs shaping first.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Plugins that build absolute URLs (sitemaps, canonical, hreflang) need to know the site's URL convention, but the plugin context (
ctx.site) only carriesname,url, andlocale. So a plugin has to hardcode a trailing slash.That's fine for Astro's default, but wrong for a site configured with
trailingSlash: 'never'. It's especially a problem for headless setups, where the front-end serves bare URLs (like/blog/post) and the plugin's sitemap then advertises/blog/post/, which the site doesn't serve.Proposal: expose Astro's
trailingSlashonctx.site, riding the same path thei18nconfig already uses (astro:config:setuptovirtual:emdash/configtoreadSiteInfotoSiteInfo). It's optional and defaults to'ignore'(Astro's default), so nothing changes for existing sites.I hit this building the
emdash-plugin-seositemap feed for a headless site. Happy to be told if there's a better approach or if it needs shaping first.Draft implementation: #2122 (core) and jdevalk/emdash-plugin-seo#2 (the consuming plugin).
Beta Was this translation helpful? Give feedback.
All reactions