Skip to content

Commit 6f3202b

Browse files
FryunipatjakubikronildoryanrussellHiDeoo
authored
Add support for SSR (#1255)
Co-authored-by: Patrick Jakubik <37963339+patryk-smc@users.noreply.github.com> Co-authored-by: Roni Costa <622159+ronildo@users.noreply.github.com> Co-authored-by: Ryan Russell <523300+ryanrussell@users.noreply.github.com> Co-authored-by: HiDeoo <494699+HiDeoo@users.noreply.github.com> Co-authored-by: Murali Manohar Varma <67296473+mmv-dev@users.noreply.github.com> Co-authored-by: Marcelo Cardoso <33183880+marcelovicentegc@users.noreply.github.com> Co-authored-by: Aaron Siddhartha Mondal <28633256+aaronmondal@users.noreply.github.com> Co-authored-by: Chris Swithinbank <357379+delucis@users.noreply.github.com> Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
1 parent 20cbf3b commit 6f3202b

48 files changed

Lines changed: 1004 additions & 146 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/ninety-singers-film.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@astrojs/starlight': patch
3+
---
4+
5+
Improves performance of computing the last updated times from Git history.
6+
7+
Instead of executing `git` for each docs page, it is now executed twice regardless of the number of pages.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@astrojs/starlight': patch
3+
---
4+
5+
Fixes last updated times on projects with custom `srcDir`

.changeset/six-phones-boil.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@astrojs/starlight': minor
3+
---
4+
5+
Adds support for server-rendered Starlight pages.
6+
7+
When building a project with `hybrid` or `server` output mode, a new `prerender` option on Starlight config can be set to `false` to make all Starlight pages be rendered on-demand:
8+
9+
```ts
10+
export default defineConfig({
11+
output: 'server',
12+
integrations: [starlight({
13+
prerender: false
14+
})],
15+
})
16+
```

docs/src/content/docs/manual-setup.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,6 @@ In the future, we plan to support this use case better to avoid the need for the
125125

126126
### Use Starlight with SSR
127127

128-
You can use Starlight alongside custom on-demand rendered pages in your project by following the [“On-demand Rendering Adapters”](https://docs.astro.build/en/guides/server-side-rendering/) guide in Astro’s docs.
128+
To enable SSR, follow the [“On-demand Rendering Adapters”](https://docs.astro.build/en/guides/server-side-rendering/) guide in Astro’s docs to add a server adapter to your Starlight project.
129129

130-
Currently, documentation pages generated by Starlight are always prerendered regardless of your project's output mode. We hope to be able to support on-demand rendering for Starlight pages soon.
130+
Documentation pages generated by Starlight are pre-rendered by default regardless of your project's output mode. To opt out of pre-rendering your Starlight pages, set the [`prerender` config option](/reference/configuration/#prerender) to `false`.

docs/src/content/docs/reference/configuration.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,18 @@ Define whether Starlight’s default site search provider [Pagefind](https://pag
455455
Set to `false` to disable indexing your site with Pagefind.
456456
This will also hide the default search UI if in use.
457457

458+
Pagefind cannot be enabled when the [`prerender`](#prerender) option is set to `false`.
459+
460+
### `prerender`
461+
462+
**type:** `boolean`
463+
**default:** `true`
464+
465+
Define whether Starlight pages should be pre-rendered to static HTML or on-demand rendered by an [SSR adapter](https://docs.astro.build/en/guides/server-side-rendering/).
466+
467+
Starlight pages are pre-rendered by default.
468+
If you are using an SSR adapter and want to render Starlight pages on demand, set `prerender: false`.
469+
458470
### `head`
459471

460472
**type:** [`HeadConfig[]`](#headconfig)

packages/starlight/.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Astro generates this during tests, but we want to ignore it.
2-
src/env.d.ts
3-
__tests__/**/env.d.ts
2+
env.d.ts
43
__tests__/**/types.d.ts
4+
.astro

packages/starlight/__e2e__/collection-config.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import { expect, testFactory } from './test-utils';
22

33
// This fixture contains a space in the directory so that we have a smoke test for building
44
// Starlight projects with pathnames like this, which are a common source of bugs.
5-
const test = await testFactory('./fixtures/custom src-dir/');
5+
const test = testFactory('./fixtures/custom src-dir/');
66

77
test('builds a custom page using the `<StarlightPage>` component and a custom `srcDir`', async ({
88
page,
9-
starlight,
9+
getProdServer,
1010
}) => {
11+
const starlight = await getProdServer();
1112
await starlight.goto('/custom');
1213

1314
await expect(page.getByText('Hello')).toBeVisible();
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This fixture is used for the E2E tests related to Git where
2+
# a new repo is created. Nested repos do not inherit the .gitignore
3+
# options from the parent repo, so even though these files are
4+
# already ignored on the package they have to be re-declared here.
5+
# Do not delete this file or the Git tests will try to index and
6+
# and commit all the node_modules and generated files from the test.
7+
env.d.ts
8+
.astro
9+
/node_modules/
10+
/dist/
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import starlight from '@astrojs/starlight';
2+
import { defineConfig } from 'astro/config';
3+
4+
export default defineConfig({
5+
integrations: [
6+
starlight({
7+
title: 'Git',
8+
pagefind: false,
9+
}),
10+
],
11+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "@e2e/git",
3+
"version": "0.0.0",
4+
"private": true,
5+
"dependencies": {
6+
"@astrojs/starlight": "workspace:*",
7+
"astro": "^4.15.3"
8+
}
9+
}

0 commit comments

Comments
 (0)