@astrojs/starlight 0.37.7 → 0.38.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +76 -0
- package/components/ContentNotice.astro +1 -1
- package/components/MobileTableOfContents.astro +2 -2
- package/components/Page.astro +3 -3
- package/components/Select.astro +2 -2
- package/components/SocialIcons.astro +1 -1
- package/components/TableOfContents.astro +2 -2
- package/global.d.ts +9 -3
- package/index.ts +39 -1
- package/integrations/asides.ts +1 -1
- package/integrations/remark-rehype.ts +2 -11
- package/integrations/virtual-user-config.ts +31 -17
- package/integrations/vite-layer-order.ts +38 -35
- package/package.json +12 -148
- package/schema.ts +5 -11
- package/schemas/badge.ts +9 -8
- package/schemas/components.ts +1 -1
- package/schemas/expressiveCode.ts +0 -3
- package/schemas/favicon.ts +4 -6
- package/schemas/head.ts +3 -2
- package/schemas/hero.ts +1 -1
- package/schemas/i18n.ts +148 -153
- package/schemas/icon.ts +1 -1
- package/schemas/pagefind.ts +5 -4
- package/schemas/prevNextLink.ts +6 -8
- package/schemas/sidebar.ts +33 -27
- package/schemas/site-title.ts +4 -6
- package/schemas/social.ts +3 -2
- package/schemas/tableOfContents.ts +17 -15
- package/style/props.css +7 -2
- package/types.ts +1 -1
- package/user-components/Aside.astro +1 -1
- package/user-components/Card.astro +1 -1
- package/user-components/Icon.astro +1 -1
- package/user-components/LinkButton.astro +1 -1
- package/user-components/TabItem.astro +1 -1
- package/user-components/rehype-file-tree.ts +1 -1
- package/user-components/rehype-tabs.ts +1 -1
- package/utils/createTranslationSystem.ts +1 -1
- package/utils/error-map.ts +98 -57
- package/utils/navigation.ts +11 -10
- package/utils/plugins.ts +75 -40
- package/utils/routing/data.ts +3 -9
- package/utils/routing/index.ts +16 -24
- package/utils/routing/types.ts +5 -17
- package/utils/slugs.ts +11 -12
- package/utils/starlight-page.ts +13 -23
- package/utils/translations.ts +3 -4
- package/utils/user-config.ts +30 -67
- package/virtual.d.ts +6 -3
- /package/{components → components-internals}/Icons.ts +0 -0
- /package/{components → components-internals}/SidebarPersistState.ts +0 -0
- /package/{components → components-internals}/TableOfContents/TableOfContentsList.astro +0 -0
- /package/{components → components-internals}/TableOfContents/starlight-toc.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,81 @@
|
|
|
1
1
|
# @astrojs/starlight
|
|
2
2
|
|
|
3
|
+
## 0.38.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#3751](https://github.com/withastro/starlight/pull/3751) [`fb955ff`](https://github.com/withastro/starlight/commit/fb955ff39c3244edf808495c557fb84ce2aab260) Thanks [@pyxelr](https://github.com/pyxelr)! - Fixes a regression causing global `tableOfContents` config to be ignored
|
|
8
|
+
|
|
9
|
+
## 0.38.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#3644](https://github.com/withastro/starlight/pull/3644) [`0d2e7ed`](https://github.com/withastro/starlight/commit/0d2e7ed74a604b028fcab0c81b4c35c0c9365343) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Adds support for Astro v6, drops support for Astro v5.
|
|
14
|
+
|
|
15
|
+
#### Upgrade Astro and dependencies
|
|
16
|
+
|
|
17
|
+
⚠️ **BREAKING CHANGE:** Astro v5 is no longer supported. Make sure you [update Astro](https://docs.astro.build/en/guides/upgrade-to/v6/) and any other official integrations at the same time as updating Starlight:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npx @astrojs/upgrade
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
_Community Starlight plugins and Astro integrations may also need to be manually updated to work with Astro v6. If you encounter any issues, please reach out to the plugin or integration author to see if it is a known issue or if an updated version is being worked on._
|
|
24
|
+
|
|
25
|
+
#### Update your collections
|
|
26
|
+
|
|
27
|
+
⚠️ **BREAKING CHANGE:** Drops support for content collections backwards compatibility.
|
|
28
|
+
|
|
29
|
+
In Astro 5.x, projects could delay upgrading to the new Content Layer API introduced for content collections because of some existing automatic backwards compatibility that was not previously behind a flag. This meant that it was possible to upgrade from Astro 4 to Astro 5 without updating your content collections, even if you had not enabled the `legacy.collections` flag. Projects would continue to build, and no errors or warnings would be displayed.
|
|
30
|
+
|
|
31
|
+
Astro v6.0 now removes this automatic legacy content collections support, along with the `legacy.collections` flag.
|
|
32
|
+
|
|
33
|
+
If you experience content collections errors after updating to v6, [check your project for any removed legacy features](https://docs.astro.build/en/guides/upgrade-to/v6/#if-you-have) that may need updating to the Content Layer API. See [the Starlight v0.30.0 upgrade guide](https://github.com/withastro/starlight/blob/main/packages/starlight/CHANGELOG.md#0300) for detailed instructions on upgrading legacy collections to the new Content Layer API.
|
|
34
|
+
|
|
35
|
+
If you are unable to make any changes to your collections at this time, including Starlight's default `docs` and `i18n` collections, you can enable the [`legacy.collectionsBackwardsCompat` flag](https://docs.astro.build/en/reference/legacy-flags/#collectionsbackwardscompat) to upgrade to v6 without updating your collections. This temporary flag preserves some legacy v4 content collections features, and will allow you to keep your collections in their current state until the legacy flag is no longer supported.
|
|
36
|
+
|
|
37
|
+
- [#3704](https://github.com/withastro/starlight/pull/3704) [`375edcc`](https://github.com/withastro/starlight/commit/375edccde7f8d18e0ce2140de0632c2ad72e3ff8) Thanks [@florian-lefebvre](https://github.com/florian-lefebvre)! - Fixes autocomplete for components exported from `@astrojs/starlight/components/*`
|
|
38
|
+
|
|
39
|
+
**⚠️ Potentially breaking change:** This change moves some files used in Starlight’s component internals out of the `components/` directory. Direct use of these files was not and is not officially supported. If you previously imported `TableOfContents/starlight-toc.ts`, `TableOfContents/TableOfContentsList.astro`, `Icons.ts`, or `SidebarPersistState.ts`, please review your code when updating.
|
|
40
|
+
|
|
41
|
+
- [#3729](https://github.com/withastro/starlight/pull/3729) [`3642625`](https://github.com/withastro/starlight/commit/3642625db19a37abb535e00036414c84e1c16933) Thanks [@delucis](https://github.com/delucis)! - Improves Starlight’s default body font stack to better support languages such as Chinese, Japanese, and Korean on Windows.
|
|
42
|
+
For most users there should be no visible change.
|
|
43
|
+
|
|
44
|
+
If you would prefer to keep the previous font stack, you can add the following custom CSS to your site:
|
|
45
|
+
|
|
46
|
+
```css
|
|
47
|
+
:root {
|
|
48
|
+
--sl-font-system: ui-sans-serif, system-ui, 'Segoe UI', Roboto,
|
|
49
|
+
'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji',
|
|
50
|
+
'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
- [#3598](https://github.com/withastro/starlight/pull/3598) [`fff38d5`](https://github.com/withastro/starlight/commit/fff38d58b637c78b0563f6b02e44a41c13106cdb) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Makes hover styles consistent in Starlight’s navigation bar
|
|
55
|
+
|
|
56
|
+
Previously, the social icon links and language/theme switchers in Starlight’s navigation bar, dimmed on hover.
|
|
57
|
+
After this change, they now increase in contrast on hover instead.
|
|
58
|
+
This matches hover behavior elsewhere, for example in the sidebar, table of contents, or search button.
|
|
59
|
+
|
|
60
|
+
⚠️ **Potentially breaking change:** this is a subtle change to the hover style colors.
|
|
61
|
+
If you want to preserve the previous styling, you can add the following [custom CSS](https://starlight.astro.build/guides/css-and-tailwind/#custom-css-styles) to your site:
|
|
62
|
+
|
|
63
|
+
```css
|
|
64
|
+
starlight-theme-select label,
|
|
65
|
+
starlight-lang-select label {
|
|
66
|
+
color: var(--sl-color-gray-1);
|
|
67
|
+
|
|
68
|
+
&:hover {
|
|
69
|
+
color: var(--sl-color-white);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.social-icons a:hover {
|
|
74
|
+
color: var(--sl-color-text-accent);
|
|
75
|
+
opacity: 0.66;
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
3
79
|
## 0.37.7
|
|
4
80
|
|
|
5
81
|
### Patch Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
import Icon from '../user-components/Icon.astro';
|
|
3
|
-
import TableOfContentsList from '
|
|
3
|
+
import TableOfContentsList from '../components-internals/TableOfContents/TableOfContentsList.astro';
|
|
4
4
|
|
|
5
5
|
const { toc } = Astro.locals.starlightRoute;
|
|
6
6
|
---
|
|
@@ -109,7 +109,7 @@ const { toc } = Astro.locals.starlightRoute;
|
|
|
109
109
|
</style>
|
|
110
110
|
|
|
111
111
|
<script>
|
|
112
|
-
import { StarlightTOC } from '
|
|
112
|
+
import { StarlightTOC } from '../components-internals/TableOfContents/starlight-toc';
|
|
113
113
|
|
|
114
114
|
class MobileStarlightTOC extends StarlightTOC {
|
|
115
115
|
override set current(link: HTMLAnchorElement) {
|
package/components/Page.astro
CHANGED
|
@@ -34,8 +34,8 @@ import printHref from '../style/print.css?url&no-inline';
|
|
|
34
34
|
const { starlightRoute } = Astro.locals;
|
|
35
35
|
|
|
36
36
|
const pagefindEnabled =
|
|
37
|
-
starlightRoute.entry.
|
|
38
|
-
!starlightRoute.entry.
|
|
37
|
+
starlightRoute.entry.id !== '404' &&
|
|
38
|
+
!starlightRoute.entry.id.endsWith('/404') &&
|
|
39
39
|
starlightRoute.entry.data.pagefind !== false;
|
|
40
40
|
|
|
41
41
|
const htmlDataAttributes: DOMStringMap = { 'data-theme': 'dark' };
|
|
@@ -84,7 +84,7 @@ if (pagefindEnabled) mainDataAttributes['data-pagefind-body'] = '';
|
|
|
84
84
|
<PageFrame>
|
|
85
85
|
<Header slot="header" />
|
|
86
86
|
{starlightRoute.hasSidebar && <Sidebar slot="sidebar" />}
|
|
87
|
-
<script src="
|
|
87
|
+
<script src="../components-internals/SidebarPersistState"></script>
|
|
88
88
|
<TwoColumnContent>
|
|
89
89
|
<PageSidebar slot="right-sidebar" />
|
|
90
90
|
<main
|
package/components/Select.astro
CHANGED
|
@@ -45,11 +45,11 @@ interface Props {
|
|
|
45
45
|
display: flex;
|
|
46
46
|
align-items: center;
|
|
47
47
|
gap: 0.25rem;
|
|
48
|
-
color: var(--sl-color-gray-
|
|
48
|
+
color: var(--sl-color-gray-2);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
label:hover {
|
|
52
|
-
color: var(--sl-color-
|
|
52
|
+
color: var(--sl-color-white);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
.icon {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
import TableOfContentsList from '
|
|
2
|
+
import TableOfContentsList from '../components-internals/TableOfContents/TableOfContentsList.astro';
|
|
3
3
|
|
|
4
4
|
const { toc } = Astro.locals.starlightRoute;
|
|
5
5
|
---
|
|
@@ -15,4 +15,4 @@ const { toc } = Astro.locals.starlightRoute;
|
|
|
15
15
|
)
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
<script src="
|
|
18
|
+
<script src="../components-internals/TableOfContents/starlight-toc"></script>
|
package/global.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
interface StarlightThemeProvider {
|
|
2
|
+
updatePickers(theme?: string): void;
|
|
3
|
+
}
|
|
4
|
+
|
|
1
5
|
export declare global {
|
|
2
|
-
var StarlightThemeProvider:
|
|
3
|
-
|
|
4
|
-
|
|
6
|
+
var StarlightThemeProvider: StarlightThemeProvider;
|
|
7
|
+
|
|
8
|
+
interface Window {
|
|
9
|
+
StarlightThemeProvider: StarlightThemeProvider;
|
|
10
|
+
}
|
|
5
11
|
}
|
package/index.ts
CHANGED
|
@@ -124,12 +124,50 @@ export default function StarlightIntegration(
|
|
|
124
124
|
absolutePathToLang,
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
+
// TODO: refactor once there is a reliable way to detect non-Node.js compatible
|
|
128
|
+
// environments, rather than relying on the presence of specific adapters/integrations.
|
|
129
|
+
const isCloudflareEnv =
|
|
130
|
+
config.adapter?.name === '@astrojs/cloudflare' ||
|
|
131
|
+
config.integrations.some(({ name }) => name === '@astrojs/cloudflare');
|
|
132
|
+
const isNodeCompatibleEnv = !isCloudflareEnv;
|
|
133
|
+
|
|
127
134
|
updateConfig({
|
|
128
135
|
vite: {
|
|
129
136
|
plugins: [
|
|
130
137
|
vitePluginStarlightCssLayerOrder(),
|
|
131
|
-
vitePluginStarlightUserConfig(
|
|
138
|
+
vitePluginStarlightUserConfig(
|
|
139
|
+
{ command, isNodeCompatibleEnv },
|
|
140
|
+
starlightConfig,
|
|
141
|
+
config,
|
|
142
|
+
pluginTranslations
|
|
143
|
+
),
|
|
132
144
|
],
|
|
145
|
+
ssr: isNodeCompatibleEnv
|
|
146
|
+
? {}
|
|
147
|
+
: {
|
|
148
|
+
optimizeDeps: {
|
|
149
|
+
include: [
|
|
150
|
+
// Prebundle some dependencies for non-Node.js compatible environments to
|
|
151
|
+
// speed up dev server start time and prevent restarts.
|
|
152
|
+
'@astrojs/cloudflare/entrypoints/server',
|
|
153
|
+
'@astrojs/starlight>i18next',
|
|
154
|
+
'@astrojs/starlight>js-yaml',
|
|
155
|
+
'@astrojs/starlight>klona/lite',
|
|
156
|
+
// TODO: once Expressive Code is refactored/fixed, remove this workaround for
|
|
157
|
+
// Expressive Code relying on CJS dependencies like postcss not compatible
|
|
158
|
+
// with non-Node.js compatible environments like Cloudflare.
|
|
159
|
+
'@astrojs/starlight>astro-expressive-code/components',
|
|
160
|
+
'@astrojs/starlight>astro-expressive-code>hast-util-select',
|
|
161
|
+
'@astrojs/starlight>astro-expressive-code>rehype',
|
|
162
|
+
'@astrojs/starlight>astro-expressive-code>unist-util-visit',
|
|
163
|
+
'@astrojs/starlight>astro-expressive-code>rehype-format',
|
|
164
|
+
'@astrojs/starlight>astro-expressive-code>hastscript',
|
|
165
|
+
'@astrojs/starlight>astro-expressive-code>hast-util-from-html',
|
|
166
|
+
'@astrojs/starlight>astro-expressive-code>hast-util-to-string',
|
|
167
|
+
'@astrojs/starlight>astro-expressive-code>@expressive-code/core>postcss',
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
},
|
|
133
171
|
},
|
|
134
172
|
markdown: {
|
|
135
173
|
remarkPlugins: [...starlightRemarkPlugins(remarkRehypeOptions)],
|
package/integrations/asides.ts
CHANGED
|
@@ -15,7 +15,7 @@ import type { Plugin, Transformer } from 'unified';
|
|
|
15
15
|
import { visit } from 'unist-util-visit';
|
|
16
16
|
import type { RemarkRehypePluginOptions } from './remark-rehype';
|
|
17
17
|
import type { StarlightIcon } from '../types';
|
|
18
|
-
import { Icons } from '../components/Icons';
|
|
18
|
+
import { Icons } from '../components-internals/Icons';
|
|
19
19
|
import { fromHtml } from 'hast-util-from-html';
|
|
20
20
|
import type { Element } from 'hast';
|
|
21
21
|
import { throwInvalidAsideIconError } from './asides-error';
|
|
@@ -21,14 +21,7 @@ export function starlightRemarkPlugins(options: RemarkRehypePluginOptions): Rema
|
|
|
21
21
|
/** List of rehype plugins to apply. */
|
|
22
22
|
export function starlightRehypePlugins(options: RemarkRehypePluginOptions): RehypePlugin[] {
|
|
23
23
|
return [
|
|
24
|
-
...(options.starlightConfig.markdown.headingLinks
|
|
25
|
-
? [
|
|
26
|
-
[
|
|
27
|
-
rehypeHeadingIds,
|
|
28
|
-
{ experimentalHeadingIdCompat: options.astroConfig.experimental?.headingIdCompat },
|
|
29
|
-
],
|
|
30
|
-
]
|
|
31
|
-
: []),
|
|
24
|
+
...(options.starlightConfig.markdown.headingLinks ? [[rehypeHeadingIds]] : []),
|
|
32
25
|
rehypePlugins(options),
|
|
33
26
|
] as RehypePlugin[];
|
|
34
27
|
}
|
|
@@ -115,9 +108,7 @@ function normalizePath(path: string) {
|
|
|
115
108
|
|
|
116
109
|
export interface RemarkRehypePluginOptions {
|
|
117
110
|
starlightConfig: Pick<StarlightConfig, 'defaultLocale' | 'locales' | 'markdown'>;
|
|
118
|
-
astroConfig: Pick<AstroConfig, 'root' | 'srcDir'
|
|
119
|
-
experimental: Pick<AstroConfig['experimental'], 'headingIdCompat'>;
|
|
120
|
-
};
|
|
111
|
+
astroConfig: Pick<AstroConfig, 'root' | 'srcDir'>;
|
|
121
112
|
useTranslations: HookParameters<'config:setup'>['useTranslations'];
|
|
122
113
|
absolutePathToLang: HookParameters<'config:setup'>['absolutePathToLang'];
|
|
123
114
|
}
|
|
@@ -7,13 +7,24 @@ import type { StarlightConfig } from '../utils/user-config';
|
|
|
7
7
|
import { getAllNewestCommitDate } from '../utils/git';
|
|
8
8
|
import type { PluginTranslations } from '../utils/plugins';
|
|
9
9
|
|
|
10
|
+
// https://vite.dev/guide/api-plugin#hook-filters
|
|
11
|
+
const pluginResolveIdIdFilter = /^virtual:starlight\//;
|
|
12
|
+
// eslint-disable-next-line no-control-regex -- virtual module prefix
|
|
13
|
+
const pluginLoadIdFilter = /^\x00virtual:starlight\//;
|
|
14
|
+
|
|
10
15
|
function resolveVirtualModuleId<T extends string>(id: T): `\0${T}` {
|
|
11
16
|
return `\0${id}`;
|
|
12
17
|
}
|
|
13
18
|
|
|
14
19
|
/** Vite plugin that exposes Starlight user config and project context via virtual modules. */
|
|
15
20
|
export function vitePluginStarlightUserConfig(
|
|
16
|
-
|
|
21
|
+
{
|
|
22
|
+
command,
|
|
23
|
+
isNodeCompatibleEnv,
|
|
24
|
+
}: {
|
|
25
|
+
command: HookParameters<'astro:config:setup'>['command'];
|
|
26
|
+
isNodeCompatibleEnv: boolean;
|
|
27
|
+
},
|
|
17
28
|
opts: StarlightConfig,
|
|
18
29
|
{
|
|
19
30
|
build,
|
|
@@ -23,7 +34,7 @@ export function vitePluginStarlightUserConfig(
|
|
|
23
34
|
trailingSlash,
|
|
24
35
|
}: Pick<AstroConfig, 'root' | 'srcDir' | 'trailingSlash'> & {
|
|
25
36
|
build: Pick<AstroConfig['build'], 'format'>;
|
|
26
|
-
legacy: Pick<AstroConfig['legacy'], '
|
|
37
|
+
legacy: Pick<AstroConfig['legacy'], 'collectionsBackwardsCompat'>;
|
|
27
38
|
},
|
|
28
39
|
pluginTranslations: PluginTranslations
|
|
29
40
|
): NonNullable<ViteUserConfig['plugins']>[number] {
|
|
@@ -49,14 +60,12 @@ export function vitePluginStarlightUserConfig(
|
|
|
49
60
|
const rootPath = fileURLToPath(root);
|
|
50
61
|
const docsPath = resolveCollectionPath('docs', srcDir);
|
|
51
62
|
|
|
52
|
-
let collectionConfigImportPath = resolve(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
// module as this would fail at build time when Rollup tries to resolve a non-existent path.
|
|
59
|
-
if (!legacy.collections && !existsSync(collectionConfigImportPath)) {
|
|
63
|
+
let collectionConfigImportPath = resolve(fileURLToPath(srcDir), './content.config.ts');
|
|
64
|
+
// If using the collections backwards compatibility mode and the config doesn't exist, fallback
|
|
65
|
+
// to the legacy location. We need to test this ahead of time as we cannot `try/catch` a failing
|
|
66
|
+
// import in the virtual module as this would fail at build time when Rollup tries to resolve a
|
|
67
|
+
// non-existent path.
|
|
68
|
+
if (legacy.collectionsBackwardsCompat && !existsSync(collectionConfigImportPath)) {
|
|
60
69
|
collectionConfigImportPath = resolve(fileURLToPath(srcDir), './content/config.ts');
|
|
61
70
|
}
|
|
62
71
|
|
|
@@ -72,13 +81,12 @@ export function vitePluginStarlightUserConfig(
|
|
|
72
81
|
'virtual:starlight/user-config': `export default ${JSON.stringify(opts)}`,
|
|
73
82
|
'virtual:starlight/project-context': `export default ${JSON.stringify({
|
|
74
83
|
build: { format: build.format },
|
|
75
|
-
legacyCollections: legacy.collections,
|
|
76
84
|
root,
|
|
77
85
|
srcDir,
|
|
78
86
|
trailingSlash,
|
|
79
87
|
})}`,
|
|
80
88
|
'virtual:starlight/git-info':
|
|
81
|
-
(command !== 'build'
|
|
89
|
+
(command !== 'build' && isNodeCompatibleEnv
|
|
82
90
|
? `import { makeAPI } from ${resolveLocalPath('../utils/git.ts')};` +
|
|
83
91
|
`const api = makeAPI(${JSON.stringify(rootPath)});`
|
|
84
92
|
: `import { makeAPI } from ${resolveLocalPath('../utils/gitInlined.ts')};` +
|
|
@@ -150,12 +158,18 @@ export function vitePluginStarlightUserConfig(
|
|
|
150
158
|
|
|
151
159
|
return {
|
|
152
160
|
name: 'vite-plugin-starlight-user-config',
|
|
153
|
-
resolveId
|
|
154
|
-
|
|
161
|
+
resolveId: {
|
|
162
|
+
filter: { id: pluginResolveIdIdFilter },
|
|
163
|
+
handler(id): string | void {
|
|
164
|
+
if (id in modules) return resolveVirtualModuleId(id);
|
|
165
|
+
},
|
|
155
166
|
},
|
|
156
|
-
load
|
|
157
|
-
|
|
158
|
-
|
|
167
|
+
load: {
|
|
168
|
+
filter: { id: pluginLoadIdFilter },
|
|
169
|
+
handler(id): string | void {
|
|
170
|
+
const resolution = resolutionMap[id];
|
|
171
|
+
if (resolution) return modules[resolution];
|
|
172
|
+
},
|
|
159
173
|
},
|
|
160
174
|
};
|
|
161
175
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { ViteUserConfig } from 'astro';
|
|
2
2
|
import MagicString from 'magic-string';
|
|
3
3
|
|
|
4
|
+
// https://vite.dev/guide/api-plugin#hook-filters
|
|
5
|
+
const pluginTransformIdIncludeFilter = /\.astro$/;
|
|
6
|
+
const pluginTransformIdExcludeFilter = /@astrojs\/starlight\/components\/StarlightPage\.astro$/;
|
|
7
|
+
const pluginTransformCodeFilter = 'StarlightPage.astro';
|
|
8
|
+
|
|
4
9
|
const starlightPageImportSource = '@astrojs/starlight/components/StarlightPage.astro';
|
|
5
10
|
|
|
6
11
|
/**
|
|
@@ -16,49 +21,47 @@ export function vitePluginStarlightCssLayerOrder(): VitePlugin {
|
|
|
16
21
|
return {
|
|
17
22
|
name: 'vite-plugin-starlight-css-layer-order',
|
|
18
23
|
enforce: 'pre',
|
|
19
|
-
transform
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
) {
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
let ast: ReturnType<typeof this.parse>;
|
|
24
|
+
transform: {
|
|
25
|
+
filter: {
|
|
26
|
+
id: { include: pluginTransformIdIncludeFilter, exclude: pluginTransformIdExcludeFilter },
|
|
27
|
+
code: pluginTransformCodeFilter,
|
|
28
|
+
},
|
|
29
|
+
handler(code, id) {
|
|
30
|
+
let ast: ReturnType<typeof this.parse>;
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
try {
|
|
33
|
+
ast = this.parse(code);
|
|
34
|
+
} catch {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
let hasStarlightPageImport = false;
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
for (const node of ast.body) {
|
|
41
|
+
if (node.type !== 'ImportDeclaration') continue;
|
|
42
|
+
if (node.source.value !== starlightPageImportSource) continue;
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
const importDefaultSpecifier = node.specifiers.find(
|
|
45
|
+
(specifier) => specifier.type === 'ImportDefaultSpecifier'
|
|
46
|
+
);
|
|
47
|
+
if (!importDefaultSpecifier) continue;
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
hasStarlightPageImport = true;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
50
52
|
|
|
51
|
-
|
|
53
|
+
if (!hasStarlightPageImport) return;
|
|
52
54
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
// Format path to unix style path.
|
|
56
|
+
const filename = id.replace(/\\/g, '/');
|
|
57
|
+
const ms = new MagicString(code, { filename });
|
|
58
|
+
ms.prepend(`import "${starlightPageImportSource}";\n`);
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
return {
|
|
61
|
+
code: ms.toString(),
|
|
62
|
+
map: ms.generateMap({ hires: 'boundary' }),
|
|
63
|
+
};
|
|
64
|
+
},
|
|
62
65
|
},
|
|
63
66
|
};
|
|
64
67
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/starlight",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.1",
|
|
4
4
|
"description": "Build beautiful, high-performance documentation websites with Astro",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -23,142 +23,7 @@
|
|
|
23
23
|
".": "./index.ts",
|
|
24
24
|
"./locals": "./locals.ts",
|
|
25
25
|
"./components": "./components.ts",
|
|
26
|
-
"./components
|
|
27
|
-
"types": "./components/LanguageSelect.astro.tsx",
|
|
28
|
-
"import": "./components/LanguageSelect.astro"
|
|
29
|
-
},
|
|
30
|
-
"./components/Select.astro": {
|
|
31
|
-
"types": "./components/Select.astro.tsx",
|
|
32
|
-
"import": "./components/Select.astro"
|
|
33
|
-
},
|
|
34
|
-
"./components/Banner.astro": {
|
|
35
|
-
"types": "./components/Banner.astro.tsx",
|
|
36
|
-
"import": "./components/Banner.astro"
|
|
37
|
-
},
|
|
38
|
-
"./components/LastUpdated.astro": {
|
|
39
|
-
"types": "./components/LastUpdated.astro.tsx",
|
|
40
|
-
"import": "./components/LastUpdated.astro"
|
|
41
|
-
},
|
|
42
|
-
"./components/Sidebar.astro": {
|
|
43
|
-
"types": "./components/Sidebar.astro.tsx",
|
|
44
|
-
"import": "./components/Sidebar.astro"
|
|
45
|
-
},
|
|
46
|
-
"./components/MarkdownContent.astro": {
|
|
47
|
-
"types": "./components/MarkdownContent.astro.tsx",
|
|
48
|
-
"import": "./components/MarkdownContent.astro"
|
|
49
|
-
},
|
|
50
|
-
"./components/SidebarPersister.astro": {
|
|
51
|
-
"types": "./components/SidebarPersister.astro.tsx",
|
|
52
|
-
"import": "./components/SidebarPersister.astro"
|
|
53
|
-
},
|
|
54
|
-
"./components/SidebarSublist.astro": {
|
|
55
|
-
"types": "./components/SidebarSublist.astro.tsx",
|
|
56
|
-
"import": "./components/SidebarSublist.astro"
|
|
57
|
-
},
|
|
58
|
-
"./components/ContentPanel.astro": {
|
|
59
|
-
"types": "./components/ContentPanel.astro.tsx",
|
|
60
|
-
"import": "./components/ContentPanel.astro"
|
|
61
|
-
},
|
|
62
|
-
"./components/MobileMenuFooter.astro": {
|
|
63
|
-
"types": "./components/MobileMenuFooter.astro.tsx",
|
|
64
|
-
"import": "./components/MobileMenuFooter.astro"
|
|
65
|
-
},
|
|
66
|
-
"./components/SiteTitle.astro": {
|
|
67
|
-
"types": "./components/SiteTitle.astro.tsx",
|
|
68
|
-
"import": "./components/SiteTitle.astro"
|
|
69
|
-
},
|
|
70
|
-
"./components/EditLink.astro": {
|
|
71
|
-
"types": "./components/EditLink.astro.tsx",
|
|
72
|
-
"import": "./components/EditLink.astro"
|
|
73
|
-
},
|
|
74
|
-
"./components/MobileMenuToggle.astro": {
|
|
75
|
-
"types": "./components/MobileMenuToggle.astro.tsx",
|
|
76
|
-
"import": "./components/MobileMenuToggle.astro"
|
|
77
|
-
},
|
|
78
|
-
"./components/SkipLink.astro": {
|
|
79
|
-
"types": "./components/SkipLink.astro.tsx",
|
|
80
|
-
"import": "./components/SkipLink.astro"
|
|
81
|
-
},
|
|
82
|
-
"./components/MobileTableOfContents.astro": {
|
|
83
|
-
"types": "./components/MobileTableOfContents.astro.tsx",
|
|
84
|
-
"import": "./components/MobileTableOfContents.astro"
|
|
85
|
-
},
|
|
86
|
-
"./components/SocialIcons.astro": {
|
|
87
|
-
"types": "./components/SocialIcons.astro.tsx",
|
|
88
|
-
"import": "./components/SocialIcons.astro"
|
|
89
|
-
},
|
|
90
|
-
"./components/FallbackContentNotice.astro": {
|
|
91
|
-
"types": "./components/FallbackContentNotice.astro.tsx",
|
|
92
|
-
"import": "./components/FallbackContentNotice.astro"
|
|
93
|
-
},
|
|
94
|
-
"./components/DraftContentNotice.astro": {
|
|
95
|
-
"types": "./components/DraftContentNotice.astro.tsx",
|
|
96
|
-
"import": "./components/DraftContentNotice.astro"
|
|
97
|
-
},
|
|
98
|
-
"./components/Page.astro": {
|
|
99
|
-
"types": "./components/Page.astro.tsx",
|
|
100
|
-
"import": "./components/Page.astro"
|
|
101
|
-
},
|
|
102
|
-
"./components/StarlightPage.astro": {
|
|
103
|
-
"types": "./components/StarlightPage.astro.tsx",
|
|
104
|
-
"import": "./components/StarlightPage.astro"
|
|
105
|
-
},
|
|
106
|
-
"./components/AnchorHeading.astro": {
|
|
107
|
-
"types": "./components/AnchorHeading.astro.tsx",
|
|
108
|
-
"import": "./components/AnchorHeading.astro"
|
|
109
|
-
},
|
|
110
|
-
"./components/Footer.astro": {
|
|
111
|
-
"types": "./components/Footer.astro.tsx",
|
|
112
|
-
"import": "./components/Footer.astro"
|
|
113
|
-
},
|
|
114
|
-
"./components/PageFrame.astro": {
|
|
115
|
-
"types": "./components/PageFrame.astro.tsx",
|
|
116
|
-
"import": "./components/PageFrame.astro"
|
|
117
|
-
},
|
|
118
|
-
"./components/TableOfContents.astro": {
|
|
119
|
-
"types": "./components/TableOfContents.astro.tsx",
|
|
120
|
-
"import": "./components/TableOfContents.astro"
|
|
121
|
-
},
|
|
122
|
-
"./components/Head.astro": {
|
|
123
|
-
"types": "./components/Head.astro.tsx",
|
|
124
|
-
"import": "./components/Head.astro"
|
|
125
|
-
},
|
|
126
|
-
"./components/PageSidebar.astro": {
|
|
127
|
-
"types": "./components/PageSidebar.astro.tsx",
|
|
128
|
-
"import": "./components/PageSidebar.astro"
|
|
129
|
-
},
|
|
130
|
-
"./components/ThemeProvider.astro": {
|
|
131
|
-
"types": "./components/ThemeProvider.astro.tsx",
|
|
132
|
-
"import": "./components/ThemeProvider.astro"
|
|
133
|
-
},
|
|
134
|
-
"./components/Header.astro": {
|
|
135
|
-
"types": "./components/Header.astro.tsx",
|
|
136
|
-
"import": "./components/Header.astro"
|
|
137
|
-
},
|
|
138
|
-
"./components/PageTitle.astro": {
|
|
139
|
-
"types": "./components/PageTitle.astro.tsx",
|
|
140
|
-
"import": "./components/PageTitle.astro"
|
|
141
|
-
},
|
|
142
|
-
"./components/ThemeSelect.astro": {
|
|
143
|
-
"types": "./components/ThemeSelect.astro.tsx",
|
|
144
|
-
"import": "./components/ThemeSelect.astro"
|
|
145
|
-
},
|
|
146
|
-
"./components/Hero.astro": {
|
|
147
|
-
"types": "./components/Hero.astro.tsx",
|
|
148
|
-
"import": "./components/Hero.astro"
|
|
149
|
-
},
|
|
150
|
-
"./components/Pagination.astro": {
|
|
151
|
-
"types": "./components/Pagination.astro.tsx",
|
|
152
|
-
"import": "./components/Pagination.astro"
|
|
153
|
-
},
|
|
154
|
-
"./components/TwoColumnContent.astro": {
|
|
155
|
-
"types": "./components/TwoColumnContent.astro.tsx",
|
|
156
|
-
"import": "./components/TwoColumnContent.astro"
|
|
157
|
-
},
|
|
158
|
-
"./components/Search.astro": {
|
|
159
|
-
"types": "./components/Search.astro.tsx",
|
|
160
|
-
"import": "./components/Search.astro"
|
|
161
|
-
},
|
|
26
|
+
"./components/*": "./components/*",
|
|
162
27
|
"./internal": "./internal.ts",
|
|
163
28
|
"./props": "./props.ts",
|
|
164
29
|
"./schema": "./schema.ts",
|
|
@@ -177,25 +42,25 @@
|
|
|
177
42
|
"./style/markdown.css": "./style/markdown.css"
|
|
178
43
|
},
|
|
179
44
|
"peerDependencies": {
|
|
180
|
-
"astro": "^
|
|
45
|
+
"astro": "^6.0.0"
|
|
181
46
|
},
|
|
182
47
|
"devDependencies": {
|
|
183
|
-
"@playwright/test": "^1.
|
|
184
|
-
"@types/node": "^
|
|
185
|
-
"@vitest/coverage-v8": "^
|
|
186
|
-
"astro": "^
|
|
48
|
+
"@playwright/test": "^1.57.0",
|
|
49
|
+
"@types/node": "^22.19.3",
|
|
50
|
+
"@vitest/coverage-v8": "^4.1.0-beta.6",
|
|
51
|
+
"astro": "^6.0.1",
|
|
187
52
|
"linkedom": "^0.18.4",
|
|
188
|
-
"vitest": "^
|
|
53
|
+
"vitest": "^4.1.0-beta.6"
|
|
189
54
|
},
|
|
190
55
|
"dependencies": {
|
|
191
|
-
"@astrojs/markdown-remark": "^
|
|
192
|
-
"@astrojs/mdx": "^
|
|
193
|
-
"@astrojs/sitemap": "^3.
|
|
56
|
+
"@astrojs/markdown-remark": "^7.0.0",
|
|
57
|
+
"@astrojs/mdx": "^5.0.0",
|
|
58
|
+
"@astrojs/sitemap": "^3.7.1",
|
|
194
59
|
"@pagefind/default-ui": "^1.3.0",
|
|
195
60
|
"@types/hast": "^3.0.4",
|
|
196
61
|
"@types/js-yaml": "^4.0.9",
|
|
197
62
|
"@types/mdast": "^4.0.4",
|
|
198
|
-
"astro-expressive-code": "^0.41.
|
|
63
|
+
"astro-expressive-code": "^0.41.6",
|
|
199
64
|
"bcp-47": "^2.1.0",
|
|
200
65
|
"hast-util-from-html": "^2.0.1",
|
|
201
66
|
"hast-util-select": "^6.0.2",
|
|
@@ -222,7 +87,6 @@
|
|
|
222
87
|
},
|
|
223
88
|
"scripts": {
|
|
224
89
|
"test": "vitest",
|
|
225
|
-
"test:legacy": "LEGACY_COLLECTIONS=true vitest",
|
|
226
90
|
"test:coverage": "vitest run --coverage",
|
|
227
91
|
"test:e2e": "pnpm test:e2e:chrome",
|
|
228
92
|
"test:e2e:chrome": "playwright install --with-deps chromium && playwright test --project chrome",
|