-
-
Notifications
You must be signed in to change notification settings - Fork 571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Starlight compatible with server output mode #1454
Conversation
🦋 Changeset detectedLatest commit: b37115f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
It took me a while to open this because I was testing locally with Starlight docs itself. It doesn't work there but not because of this change, it is due to withastro/astro#9674, which breaks the page when using the Node adapter and If anyone wants to try this locally, make sure to comment out the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great @Fryuni! Thanks also for the thorough testing, notes, and backlinks to related issues. I think that issue should obviously be fixed, but doesn’t have to block us in the meantime.
I’ve left a couple of queries — mostly requests for enlightenment — and a suggested a couple docs tweaks. Thanks again for tackling this!
@@ -43,11 +43,15 @@ export default function StarlightIntegration({ | |||
injectRoute({ | |||
pattern: '404', | |||
entrypoint: '@astrojs/starlight/404.astro', | |||
// Ensure page is pre-rendered even when project is on server output mode | |||
prerender: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mainly out of curiosity, why do we need both this AND the export const prerender
? Seems like an API smell in Astro to me, so if these are both required I’d love to understand why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is something that I noticed while working on the routing logic. Different parts of Astro core have different behavior for prerendered and on-demand routes, but those different parts don't all have access to both those methods of defining whether something is prerendered.
For example, the conflict warning about on-demand routes with the same dynamic segments runs before the file is read, so it only knows about this prerender parameter here. Another part, that generates another warning about not matching a static path in the dev server, only knows about the prerender constant from the file, not the value passed here.
So to have a consistent behavior everywhere this needs to be passed in both places.
I haven't found anything but warning that check only one of those, but I haven't checked too deeply either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could also relate to endpoints not being prerendered if just this flag is passed in (which I mentioned here: withastro/astro#7721 (comment)). But that is mostly speculation on my part, I haven't actually tried to debug that at all.
Co-authored-by: Chris Swithinbank <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking care of all that @Fryuni! Should be ready to go. Suggesting one small tweak to the changeset.
Hoping to release this tomorrow — weekend SSR fans get ready 🙌
Co-authored-by: Chris Swithinbank <[email protected]>
Makes sure we include withastro/astro#9840 which will be needed for withastro#1175
* main: (96 commits) [ci] format i18n(ko-KR): update `manual-setup.mdx` (withastro#1482) i18n(ko-KR): update `community-content.mdx` (withastro#1483) [ci] format [ci] release (withastro#1481) [ci] format Make Starlight compatible with server output mode (withastro#1454) [i18nIgnore] community content: article description copy edit (withastro#1408) [ci] format i18n(it): Updated plugins.md and community-content.mdx (withastro#1480) i18n(fr): update `resources/community-content` (withastro#1479) [ci] format i18n(it): Modified everything in the /guides folder (withastro#1456) i18n(it): Modified frontmatter.md and overrides.md (withastro#1457) i18n(es): fix syntax highlighting with `diff`-like syntax example (withastro#1477) Add CodingCat.dev stream video to community content page (withastro#1475) i18n(fr): fix frontmatter `label` default value translation (withastro#1476) [ci] format [ci] release (withastro#1474) Set default color theme in template (withastro#1473) ...
* main: (126 commits) [ci] format [ci] release (withastro#1488) Fix rendering issue for text with unhandled Markdown directives (withastro#1489) i18n(es): update community-content (withastro#1493) i18n(es): update manual-setup (withastro#1492) Updates Korean UI translations (withastro#1487) i18n(fr): update `manual-setup` (withastro#1484) [ci] format i18n(ko-KR): update `manual-setup.mdx` (withastro#1482) i18n(ko-KR): update `community-content.mdx` (withastro#1483) [ci] format [ci] release (withastro#1481) [ci] format Make Starlight compatible with server output mode (withastro#1454) [i18nIgnore] community content: article description copy edit (withastro#1408) [ci] format i18n(it): Updated plugins.md and community-content.mdx (withastro#1480) i18n(fr): update `resources/community-content` (withastro#1479) [ci] format i18n(it): Modified everything in the /guides folder (withastro#1456) ...
Description
Make projects using Starlight and
output: 'server'
build successfully.All Starlight pages will still be pre-rendered as though they were emitted for a static build.
The built-in search, powered by Pagefind, will index any custom route that is also pre-rendered, SSR routes won't be indexed.
This PR is the simplified version of #1255, making Starlight compatible with SSR projects, but not allowing any SSR on Starlight pages themselves.