From 676d1e8029b1c8f746129c906df517ebd49eacb2 Mon Sep 17 00:00:00 2001 From: HiDeoo <494699+HiDeoo@users.noreply.github.com> Date: Tue, 29 Jul 2025 16:27:08 +0200 Subject: [PATCH 01/13] chore: add repro --- .changeset/config.json | 2 +- docs/astro.config.mjs | 19 ++++++++- docs/package.json | 3 +- docs/src/pages/tests/1.astro | 35 ++++++++++++++++ docs/src/pages/tests/2.astro | 35 ++++++++++++++++ docs/src/pages/tests/3.astro | 36 +++++++++++++++++ docs/src/pages/tests/4.astro | 35 ++++++++++++++++ packages/starlight-plugin-demo/index.ts | 40 +++++++++++++++++++ packages/starlight-plugin-demo/package.json | 18 +++++++++ packages/starlight-plugin-demo/routes/5.astro | 33 +++++++++++++++ packages/starlight-plugin-demo/routes/6.astro | 33 +++++++++++++++ packages/starlight-plugin-demo/routes/7.astro | 34 ++++++++++++++++ packages/starlight-plugin-demo/routes/8.astro | 33 +++++++++++++++ pnpm-lock.yaml | 9 +++++ 14 files changed, 362 insertions(+), 3 deletions(-) create mode 100644 docs/src/pages/tests/1.astro create mode 100644 docs/src/pages/tests/2.astro create mode 100644 docs/src/pages/tests/3.astro create mode 100644 docs/src/pages/tests/4.astro create mode 100644 packages/starlight-plugin-demo/index.ts create mode 100644 packages/starlight-plugin-demo/package.json create mode 100644 packages/starlight-plugin-demo/routes/5.astro create mode 100644 packages/starlight-plugin-demo/routes/6.astro create mode 100644 packages/starlight-plugin-demo/routes/7.astro create mode 100644 packages/starlight-plugin-demo/routes/8.astro diff --git a/.changeset/config.json b/.changeset/config.json index f50e3128e03..4fca4776934 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -9,7 +9,7 @@ "access": "public", "baseBranch": "main", "updateInternalDependencies": "patch", - "ignore": ["starlight-docs", "@example/*", "starlight-file-icons-generator", "@e2e/*"], + "ignore": ["starlight-docs", "@example/*", "starlight-file-icons-generator", "@e2e/*", "starlight-plugin-demo"], "___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": { "onlyUpdatePeerDependentsWhenOutOfRange": true } diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs index a059280810c..5732ade2d84 100644 --- a/docs/astro.config.mjs +++ b/docs/astro.config.mjs @@ -3,6 +3,8 @@ import { defineConfig } from 'astro/config'; import starlight from '@astrojs/starlight'; import starlightLinksValidator from 'starlight-links-validator'; import markdocGrammar from './grammars/markdoc.tmLanguage.json'; +// TODO(HiDeoo) Delete +import starlightPluginDemo from 'starlight-plugin-demo'; export const locales = { root: { label: 'English', lang: 'en' }, @@ -70,6 +72,20 @@ export default defineConfig({ customCss: ['./src/assets/landing.css'], locales, sidebar: [ + // TODO(HiDeoo) Delete this group. + { + label: 'Tests', + items: [ + { label: '1', link: 'tests/1' }, + { label: '2', link: 'tests/2' }, + { label: '3', link: 'tests/3' }, + { label: '4', link: 'tests/4' }, + { label: '5 (plugin)', link: 'tests/5' }, + { label: '6 (plugin)', link: 'tests/6' }, + { label: '7 (plugin)', link: 'tests/7' }, + { label: '8 (plugin)', link: 'tests/8' }, + ], + }, { label: 'Start Here', translations: { @@ -189,7 +205,8 @@ export default defineConfig({ errorOnInconsistentLocale: true, }), ] - : [], + : // TODO(HiDeoo) Delete + [starlightPluginDemo()], }), ], }); diff --git a/docs/package.json b/docs/package.json index 2059be1dc02..365402b44ac 100644 --- a/docs/package.json +++ b/docs/package.json @@ -22,7 +22,8 @@ "@types/culori": "^2.1.1", "astro": "^5.6.1", "culori": "^4.0.1", - "sharp": "^0.34.2" + "sharp": "^0.34.2", + "starlight-plugin-demo": "workspace:*" }, "devDependencies": { "@playwright/test": "^1.45.0", diff --git a/docs/src/pages/tests/1.astro b/docs/src/pages/tests/1.astro new file mode 100644 index 00000000000..ba4dacb227c --- /dev/null +++ b/docs/src/pages/tests/1.astro @@ -0,0 +1,35 @@ +--- +import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro'; +import AnchorHeading from '@astrojs/starlight/components/AnchorHeading.astro'; +import { Aside, LinkButton } from '@astrojs/starlight/components'; + +// TODO(HiDeoo) delete this page and its parent directory. +--- + + + My Sub heading + +

My custom page content and a link to the home page.

+ +

+ Get started + + Configuration Reference + +

+ + + + +
+ + diff --git a/docs/src/pages/tests/2.astro b/docs/src/pages/tests/2.astro new file mode 100644 index 00000000000..5ba2e5e47d9 --- /dev/null +++ b/docs/src/pages/tests/2.astro @@ -0,0 +1,35 @@ +--- +import AnchorHeading from '@astrojs/starlight/components/AnchorHeading.astro'; +import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro'; +import { Aside, LinkButton } from '@astrojs/starlight/components'; + +// TODO(HiDeoo) delete this page and its parent directory. +--- + + + My Sub heading + +

My custom page content and a link to the home page.

+ +

+ Get started + + Configuration Reference + +

+ + + + +
+ + diff --git a/docs/src/pages/tests/3.astro b/docs/src/pages/tests/3.astro new file mode 100644 index 00000000000..53ddb813668 --- /dev/null +++ b/docs/src/pages/tests/3.astro @@ -0,0 +1,36 @@ +--- +import AnchorHeading from '@astrojs/starlight/components/AnchorHeading.astro'; +import { Aside, LinkButton } from '@astrojs/starlight/components'; +import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro'; + +// TODO(HiDeoo) delete this page and its parent directory. +--- + + + My Sub heading + +

My custom page content and a link to the home page.

+ +

+ Get started + + Configuration Reference + +

+ + + + +
+ + diff --git a/docs/src/pages/tests/4.astro b/docs/src/pages/tests/4.astro new file mode 100644 index 00000000000..1d38389f4a1 --- /dev/null +++ b/docs/src/pages/tests/4.astro @@ -0,0 +1,35 @@ +--- +import { Aside, LinkButton } from '@astrojs/starlight/components'; +import AnchorHeading from '@astrojs/starlight/components/AnchorHeading.astro'; +import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro'; + +// TODO(HiDeoo) delete this page and its parent directory. +--- + + + My Sub heading + +

My custom page content and a link to the home page.

+ +

+ Get started + + Configuration Reference + +

+ + + + +
+ + diff --git a/packages/starlight-plugin-demo/index.ts b/packages/starlight-plugin-demo/index.ts new file mode 100644 index 00000000000..398ee7fd27b --- /dev/null +++ b/packages/starlight-plugin-demo/index.ts @@ -0,0 +1,40 @@ +import type { StarlightPlugin } from '@astrojs/starlight/types'; + +// TODO(HiDeoo) Delete this entire plugin. + +export default function starlightPluginDemo(): StarlightPlugin { + return { + name: 'starlight-plugin-demo', + hooks: { + 'config:setup': async ({ addIntegration }) => { + addIntegration({ + name: 'starlight-plugin-integration', + hooks: { + 'astro:config:setup': ({ injectRoute }) => { + injectRoute({ + entrypoint: 'starlight-plugin-demo/routes/5.astro', + pattern: '/tests/5', + prerender: true, + }); + injectRoute({ + entrypoint: 'starlight-plugin-demo/routes/6.astro', + pattern: '/tests/6', + prerender: true, + }); + injectRoute({ + entrypoint: 'starlight-plugin-demo/routes/7.astro', + pattern: '/tests/7', + prerender: true, + }); + injectRoute({ + entrypoint: 'starlight-plugin-demo/routes/8.astro', + pattern: '/tests/8', + prerender: true, + }); + }, + }, + }); + }, + }, + }; +} diff --git a/packages/starlight-plugin-demo/package.json b/packages/starlight-plugin-demo/package.json new file mode 100644 index 00000000000..f7616ad09d0 --- /dev/null +++ b/packages/starlight-plugin-demo/package.json @@ -0,0 +1,18 @@ +{ + "name": "starlight-plugin-demo", + "version": "0.1.0", + "private": true, + "license": "MIT", + "type": "module", + "exports": { + ".": "./index.ts", + "./routes/5.astro": "./routes/5.astro", + "./routes/6.astro": "./routes/6.astro", + "./routes/7.astro": "./routes/7.astro", + "./routes/8.astro": "./routes/8.astro", + "./package.json": "./package.json" + }, + "devDependencies": { + "@astrojs/starlight": "^0.35.2" + } +} diff --git a/packages/starlight-plugin-demo/routes/5.astro b/packages/starlight-plugin-demo/routes/5.astro new file mode 100644 index 00000000000..570ed5db185 --- /dev/null +++ b/packages/starlight-plugin-demo/routes/5.astro @@ -0,0 +1,33 @@ +--- +import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro'; +import AnchorHeading from '@astrojs/starlight/components/AnchorHeading.astro'; +import { Aside, LinkButton } from '@astrojs/starlight/components'; +--- + + + My Sub heading + +

My custom page content and a link to the home page.

+ +

+ Get started + + Configuration Reference + +

+ + + + +
+ + diff --git a/packages/starlight-plugin-demo/routes/6.astro b/packages/starlight-plugin-demo/routes/6.astro new file mode 100644 index 00000000000..eb5e95c033e --- /dev/null +++ b/packages/starlight-plugin-demo/routes/6.astro @@ -0,0 +1,33 @@ +--- +import AnchorHeading from '@astrojs/starlight/components/AnchorHeading.astro'; +import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro'; +import { Aside, LinkButton } from '@astrojs/starlight/components'; +--- + + + My Sub heading + +

My custom page content and a link to the home page.

+ +

+ Get started + + Configuration Reference + +

+ + + + +
+ + diff --git a/packages/starlight-plugin-demo/routes/7.astro b/packages/starlight-plugin-demo/routes/7.astro new file mode 100644 index 00000000000..72438436f08 --- /dev/null +++ b/packages/starlight-plugin-demo/routes/7.astro @@ -0,0 +1,34 @@ +--- +import AnchorHeading from '@astrojs/starlight/components/AnchorHeading.astro'; +import { Aside, LinkButton } from '@astrojs/starlight/components'; +import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro'; +--- + + + My Sub heading + +

My custom page content and a link to the home page.

+ +

+ Get started + + Configuration Reference + +

+ + + + +
+ + diff --git a/packages/starlight-plugin-demo/routes/8.astro b/packages/starlight-plugin-demo/routes/8.astro new file mode 100644 index 00000000000..a72c9543014 --- /dev/null +++ b/packages/starlight-plugin-demo/routes/8.astro @@ -0,0 +1,33 @@ +--- +import { Aside, LinkButton } from '@astrojs/starlight/components'; +import AnchorHeading from '@astrojs/starlight/components/AnchorHeading.astro'; +import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro'; +--- + + + My Sub heading + +

My custom page content and a link to the home page.

+ +

+ Get started + + Configuration Reference + +

+ + + + +
+ + diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0df4f895fca..f0dc0ca35cf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -59,6 +59,9 @@ importers: sharp: specifier: ^0.34.2 version: 0.34.2 + starlight-plugin-demo: + specifier: workspace:* + version: link:../packages/starlight-plugin-demo devDependencies: '@playwright/test': specifier: ^1.45.0 @@ -265,6 +268,12 @@ importers: specifier: ^3.0.5 version: 3.1.1(@types/debug@4.1.12)(@types/node@18.16.19)(jiti@2.4.2)(lightningcss@1.29.3)(tsx@4.15.2)(yaml@2.6.1) + packages/starlight-plugin-demo: + devDependencies: + '@astrojs/starlight': + specifier: ^0.35.2 + version: link:../starlight + packages/starlight/__e2e__/fixtures/basics: dependencies: '@astrojs/starlight': From c0ffad144acbc7a46dcd0139f226f4e53ae3a9f1 Mon Sep 17 00:00:00 2001 From: HiDeoo <494699+HiDeoo@users.noreply.github.com> Date: Tue, 29 Jul 2025 17:21:36 +0200 Subject: [PATCH 02/13] feat: vite plugin --- docs/__a11y__/test-utils.ts | 13 +++- docs/src/pages/tests/1.astro | 2 +- docs/src/pages/tests/2.astro | 2 +- docs/src/pages/tests/3.astro | 2 +- docs/src/pages/tests/4.astro | 2 +- packages/starlight-plugin-demo/routes/5.astro | 2 +- packages/starlight-plugin-demo/routes/6.astro | 2 +- packages/starlight-plugin-demo/routes/7.astro | 2 +- packages/starlight-plugin-demo/routes/8.astro | 2 +- packages/starlight/index.ts | 2 + .../integrations/vite-layer-order.ts | 77 +++++++++++++++++++ packages/starlight/package.json | 1 + pnpm-lock.yaml | 3 + 13 files changed, 103 insertions(+), 9 deletions(-) create mode 100644 packages/starlight/integrations/vite-layer-order.ts diff --git a/docs/__a11y__/test-utils.ts b/docs/__a11y__/test-utils.ts index b2a9e9d7caa..44bc47915ff 100644 --- a/docs/__a11y__/test-utils.ts +++ b/docs/__a11y__/test-utils.ts @@ -68,7 +68,18 @@ class DocsSite { throw new Error('No URLs found in sitemap.'); } - const urls: string[] = []; + // TODO(HiDeoo) Revert this change + // const urls: string[] = []; + const urls: string[] = [ + 'http://localhost:4321/tests/1/', + 'http://localhost:4321/tests/2/', + 'http://localhost:4321/tests/3/', + 'http://localhost:4321/tests/4/', + 'http://localhost:4321/tests/5/', + 'http://localhost:4321/tests/6/', + 'http://localhost:4321/tests/7/', + 'http://localhost:4321/tests/8/', + ]; for (const site of sites) { const url = site.replace(config.sitemap.replace.query, config.sitemap.replace.value); diff --git a/docs/src/pages/tests/1.astro b/docs/src/pages/tests/1.astro index ba4dacb227c..0954e2a6705 100644 --- a/docs/src/pages/tests/1.astro +++ b/docs/src/pages/tests/1.astro @@ -20,7 +20,7 @@ import { Aside, LinkButton } from '@astrojs/starlight/components'; -