@astrojs/starlight 0.29.2 → 0.30.0
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 +79 -0
- package/components/Page.astro +6 -8
- package/components/Search.astro +4 -4
- package/components/SidebarPersister.astro +7 -2
- package/index.ts +11 -7
- package/integrations/shared/pathToLocale.ts +4 -4
- package/integrations/virtual-user-config.ts +21 -4
- package/loaders.ts +40 -0
- package/package.json +13 -8
- package/routes/common.astro +2 -1
- package/routes/static/404.astro +12 -10
- package/schemas/favicon.ts +3 -1
- package/style/shiki.css +2 -2
- package/translations/ca.json +42 -0
- package/translations/es.json +11 -1
- package/translations/index.ts +2 -0
- package/translations/ru.json +2 -2
- package/user-components/file-tree-icons.ts +10 -2
- package/utils/collection.ts +45 -0
- package/utils/git.ts +6 -4
- package/utils/navigation.ts +2 -2
- package/utils/plugins.ts +0 -9
- package/utils/route-data.ts +3 -7
- package/utils/routing.ts +36 -8
- package/utils/slugs.ts +1 -1
- package/utils/starlight-page.ts +6 -3
- package/virtual-internal.d.ts +1 -0
- package/components/EmptyMarkdown.md +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,84 @@
|
|
|
1
1
|
# @astrojs/starlight
|
|
2
2
|
|
|
3
|
+
## 0.30.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#2612](https://github.com/withastro/starlight/pull/2612) [`8d5a4e8`](https://github.com/withastro/starlight/commit/8d5a4e8000d9e3a4bb9ca8178767cf3d8bc48773) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Adds support for Astro v5, drops support for Astro v4.
|
|
8
|
+
|
|
9
|
+
#### Upgrade Astro and dependencies
|
|
10
|
+
|
|
11
|
+
⚠️ **BREAKING CHANGE:** Astro v4 is no longer supported. Make sure you [update Astro](https://docs.astro.build/en/guides/upgrade-to/v5/) and any other official integrations at the same time as updating Starlight:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npx @astrojs/upgrade
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
_Community Starlight plugins and Astro integrations may also need to be manually updated to work with Astro v5. 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._
|
|
18
|
+
|
|
19
|
+
#### Update your collections
|
|
20
|
+
|
|
21
|
+
⚠️ **BREAKING CHANGE:** Starlight's internal [content collections](https://docs.astro.build/en/guides/content-collections/), which organize, validate, and render your content, have been updated to use Astro's new Content Layer API and require configuration changes in your project.
|
|
22
|
+
|
|
23
|
+
1. **Move the content config file.** This file no longer lives within the `src/content/config.ts` folder and should now exist at `src/content.config.ts`.
|
|
24
|
+
1. **Edit the collection definition(s).** To update the `docs` collection, a `loader` is now required:
|
|
25
|
+
|
|
26
|
+
```diff
|
|
27
|
+
// src/content.config.ts
|
|
28
|
+
import { defineCollection } from "astro:content";
|
|
29
|
+
+import { docsLoader } from "@astrojs/starlight/loaders";
|
|
30
|
+
import { docsSchema } from "@astrojs/starlight/schema";
|
|
31
|
+
|
|
32
|
+
export const collections = {
|
|
33
|
+
- docs: defineCollection({ schema: docsSchema() }),
|
|
34
|
+
+ docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }),
|
|
35
|
+
};
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
If you are using the [`i18n` collection](https://starlight.astro.build/guides/i18n/#translate-starlights-ui) to provide translations for additional languages you support or override our default labels, you will need to update the collection definition in a similar way and remove the collection `type` which is no longer available:
|
|
39
|
+
|
|
40
|
+
```diff
|
|
41
|
+
// src/content.config.ts
|
|
42
|
+
import { defineCollection } from "astro:content";
|
|
43
|
+
+import { docsLoader, i18nLoader } from "@astrojs/starlight/loaders";
|
|
44
|
+
import { docsSchema, i18nSchema } from "@astrojs/starlight/schema";
|
|
45
|
+
|
|
46
|
+
export const collections = {
|
|
47
|
+
- docs: defineCollection({ schema: docsSchema() }),
|
|
48
|
+
+ docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }),
|
|
49
|
+
- i18n: defineCollection({ type: 'data', schema: i18nSchema() }),
|
|
50
|
+
+ i18n: defineCollection({ loader: i18nLoader(), schema: i18nSchema() }),
|
|
51
|
+
};
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
1. **Update other collections.** To update any other collections you may have, follow the [“Updating existing collections”](https://docs.astro.build/en/guides/upgrade-to/v5/#updating-existing-collections) section in the Astro 5 upgrade guide.
|
|
55
|
+
|
|
56
|
+
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.collections` flag](https://docs.astro.build/en/reference/legacy-flags/) to upgrade to v5 without updating your collections. This legacy flag exists to provide temporary backwards compatibility, and will allow you to keep your collections in their current state until the legacy flag is no longer supported.
|
|
57
|
+
|
|
58
|
+
### Patch Changes
|
|
59
|
+
|
|
60
|
+
- [#2669](https://github.com/withastro/starlight/pull/2669) [`310df7d`](https://github.com/withastro/starlight/commit/310df7d6b01f5c4a56540bdba9243fb60dace323) Thanks [@aaronperezaguilera](https://github.com/aaronperezaguilera)! - Adds Catalan UI translations
|
|
61
|
+
|
|
62
|
+
- [#2664](https://github.com/withastro/starlight/pull/2664) [`62ff007`](https://github.com/withastro/starlight/commit/62ff0074d9a3f82e46f5c62db85c04d87ff5e931) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Publishes provenance containing verifiable data to link a package back to its source repository and the specific build instructions used to publish it.
|
|
63
|
+
|
|
64
|
+
- [#2670](https://github.com/withastro/starlight/pull/2670) [`0223b42`](https://github.com/withastro/starlight/commit/0223b425249f8d1fa468e367c632467276c9c208) Thanks [@aaronperezaguilera](https://github.com/aaronperezaguilera)! - Adds Spanish UI translations for the Pagefind search modal
|
|
65
|
+
|
|
66
|
+
## 0.29.3
|
|
67
|
+
|
|
68
|
+
### Patch Changes
|
|
69
|
+
|
|
70
|
+
- [#2642](https://github.com/withastro/starlight/pull/2642) [`12750ae`](https://github.com/withastro/starlight/commit/12750ae1bc303f2c53efd25adf01428e54aced90) Thanks [@dragomano](https://github.com/dragomano)! - Updates Russian UI translations
|
|
71
|
+
|
|
72
|
+
- [#2656](https://github.com/withastro/starlight/pull/2656) [`4d543be`](https://github.com/withastro/starlight/commit/4d543bec280f3b5e00e21727d78f25756a1ced75) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Improves error message when an invalid configuration or no configuration is provided to the Starlight integration.
|
|
73
|
+
|
|
74
|
+
- [#2645](https://github.com/withastro/starlight/pull/2645) [`cf12beb`](https://github.com/withastro/starlight/commit/cf12beb91b4cb2f212dbcc0cc1ed56e79d055ff0) Thanks [@techfg](https://github.com/techfg)! - Fixes support for favicon URLs that contain a search query and/or hash
|
|
75
|
+
|
|
76
|
+
- [#2650](https://github.com/withastro/starlight/pull/2650) [`38db4ec`](https://github.com/withastro/starlight/commit/38db4ecfdb572b1f6362aca544f72f5128f5fe08) Thanks [@raviqqe](https://github.com/raviqqe)! - Moves `@types/js-yaml` package to non-dev dependencies
|
|
77
|
+
|
|
78
|
+
- [#2633](https://github.com/withastro/starlight/pull/2633) [`5adb720`](https://github.com/withastro/starlight/commit/5adb720afd354d99b3682d045b9dc8729a1ff274) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes a VoiceOver issue with Safari where the content of a `<script>` element could be read before the sidebar content.
|
|
79
|
+
|
|
80
|
+
- [#2663](https://github.com/withastro/starlight/pull/2663) [`34755f9`](https://github.com/withastro/starlight/commit/34755f9c5f2fa451e8a56aecf3ff5a6ff499767b) Thanks [@astrobot-houston](https://github.com/astrobot-houston)! - Adds a new `seti:vite` icon for Vite configuration files in the `<FileTree>` component
|
|
81
|
+
|
|
3
82
|
## 0.29.2
|
|
4
83
|
|
|
5
84
|
### Patch Changes
|
package/components/Page.astro
CHANGED
|
@@ -35,16 +35,14 @@ const pagefindEnabled =
|
|
|
35
35
|
Astro.props.entry.slug !== '404' &&
|
|
36
36
|
!Astro.props.entry.slug.endsWith('/404') &&
|
|
37
37
|
Astro.props.entry.data.pagefind !== false;
|
|
38
|
+
|
|
39
|
+
const dataAttributes: DOMStringMap = { 'data-theme': 'dark' };
|
|
40
|
+
if (Boolean(Astro.props.toc)) dataAttributes['data-has-toc'] = '';
|
|
41
|
+
if (Astro.props.hasSidebar) dataAttributes['data-has-sidebar'] = '';
|
|
42
|
+
if (Boolean(Astro.props.entry.data.hero)) dataAttributes['data-has-hero'] = '';
|
|
38
43
|
---
|
|
39
44
|
|
|
40
|
-
<html
|
|
41
|
-
lang={Astro.props.lang}
|
|
42
|
-
dir={Astro.props.dir}
|
|
43
|
-
data-has-toc={Boolean(Astro.props.toc)}
|
|
44
|
-
data-has-sidebar={Astro.props.hasSidebar}
|
|
45
|
-
data-has-hero={Boolean(Astro.props.entry.data.hero)}
|
|
46
|
-
data-theme="dark"
|
|
47
|
-
>
|
|
45
|
+
<html lang={Astro.props.lang} dir={Astro.props.dir} {...dataAttributes}>
|
|
48
46
|
<head>
|
|
49
47
|
<Head {...Astro.props} />
|
|
50
48
|
<style>
|
package/components/Search.astro
CHANGED
|
@@ -12,12 +12,12 @@ const pagefindTranslations = {
|
|
|
12
12
|
.map(([key, value]) => [key.replace('pagefind.', ''), value])
|
|
13
13
|
),
|
|
14
14
|
};
|
|
15
|
+
|
|
16
|
+
const dataAttributes: DOMStringMap = { 'data-translations': JSON.stringify(pagefindTranslations) };
|
|
17
|
+
if (project.trailingSlash === 'never') dataAttributes['data-strip-trailing-slash'] = '';
|
|
15
18
|
---
|
|
16
19
|
|
|
17
|
-
<site-search
|
|
18
|
-
data-translations={JSON.stringify(pagefindTranslations)}
|
|
19
|
-
data-strip-trailing-slash={project.trailingSlash === 'never'}
|
|
20
|
-
>
|
|
20
|
+
<site-search class={Astro.props.class} {...dataAttributes}>
|
|
21
21
|
<button
|
|
22
22
|
data-open-modal
|
|
23
23
|
disabled
|
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
- On smaller viewports, restoring state is skipped as the sidebar is collapsed inside a menu.
|
|
13
13
|
- The state is parsed from session storage and restored.
|
|
14
14
|
- This is a progressive enhancement, so any errors are swallowed silently.
|
|
15
|
+
|
|
16
|
+
The `aria-hidden` attribute on script tags is used to prevent a Safari/VoiceOver bug where the
|
|
17
|
+
script is read out loud due to them being inside a container with `display: contents`.
|
|
18
|
+
@see https://bugs.webkit.org/show_bug.cgi?id=283645
|
|
19
|
+
@see https://github.com/withastro/starlight/pull/2633
|
|
15
20
|
*/
|
|
16
21
|
|
|
17
22
|
import type { Props } from '../props';
|
|
@@ -28,7 +33,7 @@ declare global {
|
|
|
28
33
|
---
|
|
29
34
|
|
|
30
35
|
<sl-sidebar-state-persist data-hash={hash}>
|
|
31
|
-
<script is:inline>
|
|
36
|
+
<script is:inline aria-hidden="true">
|
|
32
37
|
(() => {
|
|
33
38
|
try {
|
|
34
39
|
if (!matchMedia('(min-width: 50em)').matches) return;
|
|
@@ -55,7 +60,7 @@ declare global {
|
|
|
55
60
|
|
|
56
61
|
<slot />
|
|
57
62
|
|
|
58
|
-
<script is:inline>
|
|
63
|
+
<script is:inline aria-hidden="true">
|
|
59
64
|
(() => {
|
|
60
65
|
const scroller = document.getElementById('starlight__sidebar');
|
|
61
66
|
if (!window._starlightScrollRestore || !scroller) return;
|
package/index.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import mdx from '@astrojs/mdx';
|
|
11
11
|
import type { AstroIntegration } from 'astro';
|
|
12
|
+
import { AstroError } from 'astro/errors';
|
|
12
13
|
import { spawn } from 'node:child_process';
|
|
13
14
|
import { dirname, relative } from 'node:path';
|
|
14
15
|
import { fileURLToPath } from 'node:url';
|
|
@@ -27,10 +28,16 @@ import {
|
|
|
27
28
|
import { processI18nConfig } from './utils/i18n';
|
|
28
29
|
import type { StarlightConfig } from './types';
|
|
29
30
|
|
|
30
|
-
export default function StarlightIntegration(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
export default function StarlightIntegration(
|
|
32
|
+
userOpts: StarlightUserConfigWithPlugins
|
|
33
|
+
): AstroIntegration {
|
|
34
|
+
if (typeof userOpts !== 'object' || userOpts === null || Array.isArray(userOpts))
|
|
35
|
+
throw new AstroError(
|
|
36
|
+
'Invalid config passed to starlight integration',
|
|
37
|
+
`The Starlight integration expects a configuration object with at least a \`title\` property.\n\n` +
|
|
38
|
+
`See more details in the [Starlight configuration reference](https://starlight.astro.build/reference/configuration/)\n`
|
|
39
|
+
);
|
|
40
|
+
const { plugins, ...opts } = userOpts;
|
|
34
41
|
let userConfig: StarlightConfig;
|
|
35
42
|
let pluginTranslations: PluginTranslations = {};
|
|
36
43
|
return {
|
|
@@ -130,9 +137,6 @@ export default function StarlightIntegration({
|
|
|
130
137
|
scopedStyleStrategy: 'where',
|
|
131
138
|
// If not already configured, default to prefetching all links on hover.
|
|
132
139
|
prefetch: config.prefetch ?? { prefetchAll: true },
|
|
133
|
-
experimental: {
|
|
134
|
-
globalRoutePriority: true,
|
|
135
|
-
},
|
|
136
140
|
i18n: astroI18nConfig,
|
|
137
141
|
});
|
|
138
142
|
},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AstroConfig } from 'astro';
|
|
2
2
|
import type { StarlightConfig } from '../../types';
|
|
3
|
+
import { getCollectionPath } from '../../utils/collection';
|
|
3
4
|
import { slugToLocale } from './slugToLocale';
|
|
4
5
|
|
|
5
6
|
/** Get current locale from the full file path. */
|
|
@@ -13,15 +14,14 @@ export function pathToLocale(
|
|
|
13
14
|
astroConfig: { root: AstroConfig['root']; srcDir: AstroConfig['srcDir'] };
|
|
14
15
|
}
|
|
15
16
|
): string | undefined {
|
|
16
|
-
const
|
|
17
|
-
const docsDir = new URL('content/docs/', srcDir);
|
|
17
|
+
const docsPath = getCollectionPath('docs', astroConfig.srcDir);
|
|
18
18
|
// Format path to unix style path.
|
|
19
19
|
path = path?.replace(/\\/g, '/');
|
|
20
20
|
// Ensure that the page path starts with a slash if the docs directory also does,
|
|
21
21
|
// which makes stripping the docs path in the next step work on Windows, too.
|
|
22
|
-
if (path && !path.startsWith('/') &&
|
|
22
|
+
if (path && !path.startsWith('/') && docsPath.startsWith('/')) path = '/' + path;
|
|
23
23
|
// Strip docs path leaving only content collection file ID.
|
|
24
24
|
// Example: /Users/houston/repo/src/content/docs/en/guide.md => en/guide.md
|
|
25
|
-
const slug = path?.replace(
|
|
25
|
+
const slug = path?.replace(docsPath, '');
|
|
26
26
|
return slugToLocale(slug, starlightConfig);
|
|
27
27
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { AstroConfig, HookParameters, ViteUserConfig } from 'astro';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
2
3
|
import { resolve } from 'node:path';
|
|
3
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { resolveCollectionPath } from '../utils/collection';
|
|
4
6
|
import type { StarlightConfig } from '../utils/user-config';
|
|
5
7
|
import { getAllNewestCommitDate } from '../utils/git';
|
|
6
8
|
import type { PluginTranslations } from '../utils/plugins';
|
|
@@ -15,11 +17,13 @@ export function vitePluginStarlightUserConfig(
|
|
|
15
17
|
opts: StarlightConfig,
|
|
16
18
|
{
|
|
17
19
|
build,
|
|
20
|
+
legacy,
|
|
18
21
|
root,
|
|
19
22
|
srcDir,
|
|
20
23
|
trailingSlash,
|
|
21
24
|
}: Pick<AstroConfig, 'root' | 'srcDir' | 'trailingSlash'> & {
|
|
22
25
|
build: Pick<AstroConfig['build'], 'format'>;
|
|
26
|
+
legacy: Pick<AstroConfig['legacy'], 'collections'>;
|
|
23
27
|
},
|
|
24
28
|
pluginTranslations: PluginTranslations
|
|
25
29
|
): NonNullable<ViteUserConfig['plugins']>[number] {
|
|
@@ -42,7 +46,19 @@ export function vitePluginStarlightUserConfig(
|
|
|
42
46
|
const resolveLocalPath = (path: string) =>
|
|
43
47
|
JSON.stringify(fileURLToPath(new URL(path, import.meta.url)));
|
|
44
48
|
|
|
45
|
-
const
|
|
49
|
+
const rootPath = fileURLToPath(root);
|
|
50
|
+
const docsPath = resolveCollectionPath('docs', srcDir);
|
|
51
|
+
|
|
52
|
+
let collectionConfigImportPath = resolve(
|
|
53
|
+
fileURLToPath(srcDir),
|
|
54
|
+
legacy.collections ? './content/config.ts' : './content.config.ts'
|
|
55
|
+
);
|
|
56
|
+
// If not using legacy collections and the config doesn't exist, fallback to the legacy location.
|
|
57
|
+
// We need to test this ahead of time as we cannot `try/catch` a failing import in the virtual
|
|
58
|
+
// module as this would fail at build time when Rollup tries to resolve a non-existent path.
|
|
59
|
+
if (!legacy.collections && !existsSync(collectionConfigImportPath)) {
|
|
60
|
+
collectionConfigImportPath = resolve(fileURLToPath(srcDir), './content/config.ts');
|
|
61
|
+
}
|
|
46
62
|
|
|
47
63
|
const virtualComponentModules = Object.fromEntries(
|
|
48
64
|
Object.entries(opts.components).map(([name, path]) => [
|
|
@@ -56,6 +72,7 @@ export function vitePluginStarlightUserConfig(
|
|
|
56
72
|
'virtual:starlight/user-config': `export default ${JSON.stringify(opts)}`,
|
|
57
73
|
'virtual:starlight/project-context': `export default ${JSON.stringify({
|
|
58
74
|
build: { format: build.format },
|
|
75
|
+
legacyCollections: legacy.collections,
|
|
59
76
|
root,
|
|
60
77
|
srcDir,
|
|
61
78
|
trailingSlash,
|
|
@@ -63,9 +80,9 @@ export function vitePluginStarlightUserConfig(
|
|
|
63
80
|
'virtual:starlight/git-info':
|
|
64
81
|
(command !== 'build'
|
|
65
82
|
? `import { makeAPI } from ${resolveLocalPath('../utils/git.ts')};` +
|
|
66
|
-
`const api = makeAPI(${JSON.stringify(
|
|
83
|
+
`const api = makeAPI(${JSON.stringify(rootPath)});`
|
|
67
84
|
: `import { makeAPI } from ${resolveLocalPath('../utils/gitInlined.ts')};` +
|
|
68
|
-
`const api = makeAPI(${JSON.stringify(getAllNewestCommitDate(docsPath))});`) +
|
|
85
|
+
`const api = makeAPI(${JSON.stringify(getAllNewestCommitDate(rootPath, docsPath))});`) +
|
|
69
86
|
'export const getNewestCommitDate = api.getNewestCommitDate;',
|
|
70
87
|
'virtual:starlight/user-css': opts.customCss.map((id) => `import ${resolveId(id)};`).join(''),
|
|
71
88
|
'virtual:starlight/user-images': opts.logo
|
|
@@ -79,7 +96,7 @@ export function vitePluginStarlightUserConfig(
|
|
|
79
96
|
: 'export const logos = {};',
|
|
80
97
|
'virtual:starlight/collection-config': `let userCollections;
|
|
81
98
|
try {
|
|
82
|
-
userCollections = (await import(${
|
|
99
|
+
userCollections = (await import(${JSON.stringify(collectionConfigImportPath)})).collections;
|
|
83
100
|
} catch {}
|
|
84
101
|
export const collections = userCollections;`,
|
|
85
102
|
'virtual:starlight/plugin-translations': `export default ${JSON.stringify(pluginTranslations)}`,
|
package/loaders.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { glob, type Loader, type LoaderContext } from 'astro/loaders';
|
|
2
|
+
import { getCollectionPathFromRoot, type StarlightCollection } from './utils/collection';
|
|
3
|
+
|
|
4
|
+
// https://github.com/withastro/astro/blob/main/packages/astro/src/core/constants.ts#L87
|
|
5
|
+
// https://github.com/withastro/astro/blob/main/packages/integrations/mdx/src/index.ts#L59
|
|
6
|
+
const docsExtensions = ['markdown', 'mdown', 'mkdn', 'mkd', 'mdwn', 'md', 'mdx'];
|
|
7
|
+
const i18nExtensions = ['json', 'yml', 'yaml'];
|
|
8
|
+
|
|
9
|
+
export function docsLoader(): Loader {
|
|
10
|
+
return {
|
|
11
|
+
name: 'starlight-docs-loader',
|
|
12
|
+
load: createGlobLoadFn('docs'),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function i18nLoader(): Loader {
|
|
17
|
+
return {
|
|
18
|
+
name: 'starlight-i18n-loader',
|
|
19
|
+
load: createGlobLoadFn('i18n'),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function createGlobLoadFn(collection: StarlightCollection): Loader['load'] {
|
|
24
|
+
return (context: LoaderContext) => {
|
|
25
|
+
const extensions = collection === 'docs' ? docsExtensions : i18nExtensions;
|
|
26
|
+
|
|
27
|
+
if (
|
|
28
|
+
collection === 'docs' &&
|
|
29
|
+
context.config.integrations.find(({ name }) => name === '@astrojs/markdoc')
|
|
30
|
+
) {
|
|
31
|
+
// https://github.com/withastro/astro/blob/main/packages/integrations/markdoc/src/content-entry-type.ts#L28
|
|
32
|
+
extensions.push('mdoc');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return glob({
|
|
36
|
+
base: getCollectionPathFromRoot(collection, context.config),
|
|
37
|
+
pattern: `**/[^_]*.{${extensions.join(',')}}`,
|
|
38
|
+
}).load(context);
|
|
39
|
+
};
|
|
40
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/starlight",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.0",
|
|
4
4
|
"description": "Build beautiful, high-performance documentation websites with Astro",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -158,6 +158,7 @@
|
|
|
158
158
|
"./internal": "./internal.ts",
|
|
159
159
|
"./props": "./props.ts",
|
|
160
160
|
"./schema": "./schema.ts",
|
|
161
|
+
"./loaders": "./loaders.ts",
|
|
161
162
|
"./types": "./types.ts",
|
|
162
163
|
"./expressive-code": {
|
|
163
164
|
"types": "./expressive-code.d.ts",
|
|
@@ -171,23 +172,23 @@
|
|
|
171
172
|
"./style/markdown.css": "./style/markdown.css"
|
|
172
173
|
},
|
|
173
174
|
"peerDependencies": {
|
|
174
|
-
"astro": "^
|
|
175
|
+
"astro": "^5.0.0"
|
|
175
176
|
},
|
|
176
177
|
"devDependencies": {
|
|
177
|
-
"@astrojs/markdown-remark": "^
|
|
178
|
+
"@astrojs/markdown-remark": "^6.0.0",
|
|
178
179
|
"@playwright/test": "^1.45.0",
|
|
179
|
-
"@types/js-yaml": "^4.0.9",
|
|
180
180
|
"@types/node": "^18.16.19",
|
|
181
|
-
"@vitest/coverage-v8": "
|
|
182
|
-
"astro": "^
|
|
181
|
+
"@vitest/coverage-v8": "2.1.6",
|
|
182
|
+
"astro": "^5.0.2",
|
|
183
183
|
"linkedom": "^0.18.4",
|
|
184
|
-
"vitest": "
|
|
184
|
+
"vitest": "2.1.6"
|
|
185
185
|
},
|
|
186
186
|
"dependencies": {
|
|
187
|
-
"@astrojs/mdx": "^
|
|
187
|
+
"@astrojs/mdx": "^4.0.1",
|
|
188
188
|
"@astrojs/sitemap": "^3.1.6",
|
|
189
189
|
"@pagefind/default-ui": "^1.0.3",
|
|
190
190
|
"@types/hast": "^3.0.4",
|
|
191
|
+
"@types/js-yaml": "^4.0.9",
|
|
191
192
|
"@types/mdast": "^4.0.4",
|
|
192
193
|
"astro-expressive-code": "^0.38.3",
|
|
193
194
|
"bcp-47": "^2.1.0",
|
|
@@ -208,8 +209,12 @@
|
|
|
208
209
|
"unist-util-visit": "^5.0.0",
|
|
209
210
|
"vfile": "^6.0.2"
|
|
210
211
|
},
|
|
212
|
+
"publishConfig": {
|
|
213
|
+
"provenance": true
|
|
214
|
+
},
|
|
211
215
|
"scripts": {
|
|
212
216
|
"test": "vitest",
|
|
217
|
+
"test:legacy": "LEGACY_COLLECTIONS=true vitest",
|
|
213
218
|
"test:coverage": "vitest run --coverage",
|
|
214
219
|
"test:e2e": "playwright install --with-deps chromium && playwright test"
|
|
215
220
|
}
|
package/routes/common.astro
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
+
import { render } from 'astro:content';
|
|
2
3
|
import { generateRouteData } from '../utils/route-data';
|
|
3
4
|
import type { Route } from '../utils/routing';
|
|
4
5
|
import Page from '../components/Page.astro';
|
|
@@ -9,7 +10,7 @@ export type Props = {
|
|
|
9
10
|
|
|
10
11
|
const { route } = Astro.props;
|
|
11
12
|
|
|
12
|
-
const { Content, headings } = await route.entry
|
|
13
|
+
const { Content, headings } = await render(route.entry);
|
|
13
14
|
const routeData = generateRouteData({ props: { ...route, headings }, url: Astro.url });
|
|
14
15
|
---
|
|
15
16
|
|
package/routes/static/404.astro
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { getEntry } from 'astro:content';
|
|
3
|
+
import project from 'virtual:starlight/project-context';
|
|
3
4
|
import config from 'virtual:starlight/user-config';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
5
|
+
import { getCollectionPathFromRoot } from '../../utils/collection';
|
|
6
|
+
import {
|
|
7
|
+
normalizeCollectionEntry,
|
|
8
|
+
type Route,
|
|
9
|
+
type StarlightDocsCollectionEntry,
|
|
10
|
+
type StarlightDocsEntry,
|
|
11
|
+
} from '../../utils/routing';
|
|
6
12
|
import { BuiltInDefaultLocale } from '../../utils/i18n';
|
|
7
13
|
import CommonPage from '../common.astro';
|
|
8
14
|
|
|
@@ -17,7 +23,7 @@ const entryMeta = { dir, lang, locale };
|
|
|
17
23
|
|
|
18
24
|
const fallbackEntry: StarlightDocsEntry = {
|
|
19
25
|
slug: '404',
|
|
20
|
-
id: '404
|
|
26
|
+
id: '404',
|
|
21
27
|
body: '',
|
|
22
28
|
collection: 'docs',
|
|
23
29
|
data: {
|
|
@@ -30,15 +36,11 @@ const fallbackEntry: StarlightDocsEntry = {
|
|
|
30
36
|
sidebar: { hidden: false, attrs: {} },
|
|
31
37
|
draft: false,
|
|
32
38
|
},
|
|
33
|
-
|
|
34
|
-
Content: EmptyContent,
|
|
35
|
-
headings: [],
|
|
36
|
-
remarkPluginFrontmatter: {},
|
|
37
|
-
}),
|
|
39
|
+
filePath: `${getCollectionPathFromRoot('docs', project)}/404.md`,
|
|
38
40
|
};
|
|
39
41
|
|
|
40
|
-
const userEntry = await getEntry('docs', '404');
|
|
41
|
-
const entry = userEntry
|
|
42
|
+
const userEntry = (await getEntry('docs', '404')) as StarlightDocsCollectionEntry;
|
|
43
|
+
const entry = userEntry ? normalizeCollectionEntry(userEntry) : fallbackEntry;
|
|
42
44
|
const route: Route = { ...entryMeta, entryMeta, entry, id: entry.id, slug: entry.slug };
|
|
43
45
|
---
|
|
44
46
|
|
package/schemas/favicon.ts
CHANGED
|
@@ -15,7 +15,9 @@ export const FaviconSchema = () =>
|
|
|
15
15
|
.string()
|
|
16
16
|
.default('/favicon.svg')
|
|
17
17
|
.transform((favicon, ctx) => {
|
|
18
|
-
|
|
18
|
+
// favicon can be absolute or relative url
|
|
19
|
+
const { pathname } = new URL(favicon, 'https://example.com');
|
|
20
|
+
const ext = extname(pathname).toLowerCase();
|
|
19
21
|
|
|
20
22
|
if (!isFaviconExt(ext)) {
|
|
21
23
|
ctx.addIssue({
|
package/style/shiki.css
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
:root {
|
|
2
|
-
--astro-code-
|
|
3
|
-
--astro-code-
|
|
2
|
+
--astro-code-foreground: var(--sl-color-white);
|
|
3
|
+
--astro-code-background: var(--sl-color-gray-6);
|
|
4
4
|
--astro-code-token-constant: var(--sl-color-blue-high);
|
|
5
5
|
--astro-code-token-string: var(--sl-color-green-high);
|
|
6
6
|
--astro-code-token-comment: var(--sl-color-gray-2);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"skipLink.label": "Saltar al contingut",
|
|
3
|
+
"search.label": "Cercar",
|
|
4
|
+
"search.ctrlKey": "Ctrl",
|
|
5
|
+
"search.cancelLabel": "Cancel·lar",
|
|
6
|
+
"search.devWarning": "La cerca només està disponible a les versions de producció. \nProva de construir i previsualitzar el lloc per provar-ho localment.",
|
|
7
|
+
"themeSelect.accessibleLabel": "Seleccionar tema",
|
|
8
|
+
"themeSelect.dark": "Fosc",
|
|
9
|
+
"themeSelect.light": "Clar",
|
|
10
|
+
"themeSelect.auto": "Automàtic",
|
|
11
|
+
"languageSelect.accessibleLabel": "Seleccionar idioma",
|
|
12
|
+
"menuButton.accessibleLabel": "Menú",
|
|
13
|
+
"sidebarNav.accessibleLabel": "Primari",
|
|
14
|
+
"tableOfContents.onThisPage": "En aquesta pàgina",
|
|
15
|
+
"tableOfContents.overview": "Sinopsi",
|
|
16
|
+
"i18n.untranslatedContent": "Aquesta pàgina encara no està disponible en el teu idioma.",
|
|
17
|
+
"page.editLink": "Edita aquesta pàgina",
|
|
18
|
+
"page.lastUpdated": "Última actualització:",
|
|
19
|
+
"page.previousLink": "Pàgina anterior",
|
|
20
|
+
"page.nextLink": "Pàgina següent",
|
|
21
|
+
"page.draft": "Aquest contingut és un esborrany i no s'inclourà en les versions de producció.",
|
|
22
|
+
"404.text": "Pàgina no trobada. Comprova la URL o intenta utilitzar la barra de cerca.",
|
|
23
|
+
"aside.note": "Nota",
|
|
24
|
+
"aside.tip": "Consell",
|
|
25
|
+
"aside.caution": "Precaució",
|
|
26
|
+
"aside.danger": "Perill",
|
|
27
|
+
"expressiveCode.copyButtonCopied": "Copiat!",
|
|
28
|
+
"expressiveCode.copyButtonTooltip": "Copiar al porta-retalls",
|
|
29
|
+
"expressiveCode.terminalWindowFallbackTitle": "Finestra del terminal",
|
|
30
|
+
"fileTree.directory": "Directori",
|
|
31
|
+
"builtWithStarlight.label": "Fet amb Starlight",
|
|
32
|
+
"pagefind.clear_search": "Netejar",
|
|
33
|
+
"pagefind.load_more": "Carregar més resultats",
|
|
34
|
+
"pagefind.search_label": "Cercar pàgina",
|
|
35
|
+
"pagefind.filters_label": "Filtres",
|
|
36
|
+
"pagefind.zero_results": "Cap resultat per a: [SEARCH_TERM]",
|
|
37
|
+
"pagefind.many_results": "[COUNT] resultats per a: [SEARCH_TERM]",
|
|
38
|
+
"pagefind.one_result": "[COUNT] resultat per a: [SEARCH_TERM]",
|
|
39
|
+
"pagefind.alt_search": "Cap resultat per a [SEARCH_TERM]. Mostrant resultats per a: [DIFFERENT_TERM]",
|
|
40
|
+
"pagefind.search_suggestion": "Cap resultat per a [SEARCH_TERM]. Prova alguna d’aquestes cerques:",
|
|
41
|
+
"pagefind.searching": "Cercant [SEARCH_TERM]..."
|
|
42
|
+
}
|
package/translations/es.json
CHANGED
|
@@ -28,5 +28,15 @@
|
|
|
28
28
|
"expressiveCode.copyButtonTooltip": "Copiar al portapapeles",
|
|
29
29
|
"expressiveCode.terminalWindowFallbackTitle": "Ventana de terminal",
|
|
30
30
|
"fileTree.directory": "Directory",
|
|
31
|
-
"builtWithStarlight.label": "Hecho con Starlight"
|
|
31
|
+
"builtWithStarlight.label": "Hecho con Starlight",
|
|
32
|
+
"pagefind.clear_search": "Limpiar",
|
|
33
|
+
"pagefind.load_more": "Cargar más resultados",
|
|
34
|
+
"pagefind.search_label": "Buscar página",
|
|
35
|
+
"pagefind.filters_label": "Filtros",
|
|
36
|
+
"pagefind.zero_results": "Ningún resultado para: [SEARCH_TERM]",
|
|
37
|
+
"pagefind.many_results": "[COUNT] resultados para: [SEARCH_TERM]",
|
|
38
|
+
"pagefind.one_result": "[COUNT] resultado para: [SEARCH_TERM]",
|
|
39
|
+
"pagefind.alt_search": "Ningún resultado para [SEARCH_TERM]. Mostrando resultados para: [DIFFERENT_TERM]",
|
|
40
|
+
"pagefind.search_suggestion": "Ningún resultado para [SEARCH_TERM]. Prueba alguna de estas búsquedas:",
|
|
41
|
+
"pagefind.searching": "Buscando [SEARCH_TERM]..."
|
|
32
42
|
}
|
package/translations/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { builtinI18nSchema } from '../schemas/i18n';
|
|
|
2
2
|
import cs from './cs.json';
|
|
3
3
|
import en from './en.json';
|
|
4
4
|
import es from './es.json';
|
|
5
|
+
import ca from './ca.json';
|
|
5
6
|
import de from './de.json';
|
|
6
7
|
import ja from './ja.json';
|
|
7
8
|
import pt from './pt.json';
|
|
@@ -35,6 +36,7 @@ export default Object.fromEntries(
|
|
|
35
36
|
cs,
|
|
36
37
|
en,
|
|
37
38
|
es,
|
|
39
|
+
ca,
|
|
38
40
|
de,
|
|
39
41
|
ja,
|
|
40
42
|
pt,
|
package/translations/ru.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"search.label": "Поиск",
|
|
4
4
|
"search.ctrlKey": "Ctrl",
|
|
5
5
|
"search.cancelLabel": "Отменить",
|
|
6
|
-
"search.devWarning": "Поиск доступен только в
|
|
6
|
+
"search.devWarning": "Поиск доступен только в продакшен-сборках. \nВыполните сборку и запустите превью, чтобы протестировать поиск локально.",
|
|
7
7
|
"themeSelect.accessibleLabel": "Выберите тему",
|
|
8
8
|
"themeSelect.dark": "Тёмная",
|
|
9
9
|
"themeSelect.light": "Светлая",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"page.lastUpdated": "Последнее обновление:",
|
|
19
19
|
"page.previousLink": "Предыдущая",
|
|
20
20
|
"page.nextLink": "Следующая",
|
|
21
|
-
"page.draft": "Этот контент является черновиком и не будет добавлен в
|
|
21
|
+
"page.draft": "Этот контент является черновиком и не будет добавлен в продакшен-сборки.",
|
|
22
22
|
"404.text": "Страница не найдена. Проверьте URL или используйте поиск по сайту.",
|
|
23
23
|
"aside.note": "Заметка",
|
|
24
24
|
"aside.tip": "Совет",
|
|
@@ -62,6 +62,12 @@ export const definitions: Definitions = {
|
|
|
62
62
|
mvnw: 'seti:maven',
|
|
63
63
|
'pom.xml': 'seti:maven',
|
|
64
64
|
'tsconfig.json': 'seti:tsconfig',
|
|
65
|
+
'vite.config.js': 'seti:vite',
|
|
66
|
+
'vite.config.ts': 'seti:vite',
|
|
67
|
+
'vite.config.mjs': 'seti:vite',
|
|
68
|
+
'vite.config.mts': 'seti:vite',
|
|
69
|
+
'vite.config.cjs': 'seti:vite',
|
|
70
|
+
'vite.config.cts': 'seti:vite',
|
|
65
71
|
'swagger.json': 'seti:json',
|
|
66
72
|
'swagger.yml': 'seti:json',
|
|
67
73
|
'swagger.yaml': 'seti:json',
|
|
@@ -570,7 +576,7 @@ export const FileIcons = {
|
|
|
570
576
|
'seti:jade':
|
|
571
577
|
'<path d="M23.247 16.411L23.247 16.411Q22.923 14.719 23.103 12.595L23.103 12.595Q23.247 11.911 23.247 11.551L23.247 11.551Q23.283 10.975 23.103 10.435L23.103 10.435Q22.887 9.751 22.671 8.419L22.671 8.419L22.635 8.203Q22.419 6.799 22.275 6.079L22.275 6.079Q22.023 4.855 21.663 3.919L21.663 3.919Q21.447 3.523 21.267 3.343L21.267 3.343Q21.015 3.127 20.655 3.127L20.655 3.127Q19.971 3.127 19.971 3.811L19.971 3.811Q20.007 4.315 20.187 5.377Q20.367 6.439 20.403 6.943L20.403 6.943Q20.475 7.339 20.637 8.077Q20.799 8.815 20.871 9.211L20.871 9.211L20.871 9.643Q20.547 9.643 20.403 9.535L20.403 9.535L20.043 9.283Q19.431 8.851 19.179 8.527L19.179 8.527Q18.351 7.339 17.847 6.151L17.847 6.151L17.307 4.927Q16.371 2.659 15.795 1.687L15.795 1.687Q15.327 0.895 14.607 0.571L14.607 0.571Q14.031 0.319 13.095 0.319L13.095 0.319Q12.663 0.319 12.663 0.751L12.663 0.751L12.735 1.111Q12.843 1.543 12.987 1.795L12.987 1.795Q13.491 2.695 14.445 4.549Q15.399 6.403 15.903 7.303L15.903 7.303Q16.191 7.735 16.839 8.599L16.839 8.599L17.055 8.851Q17.379 9.355 17.307 9.607Q17.235 9.859 16.695 10.111L16.695 10.111L16.587 10.111L16.479 10.219Q15.327 10.507 14.355 9.535L14.355 9.535Q13.419 8.815 12.303 8.635L12.303 8.635Q12.159 8.635 11.763 8.581Q11.367 8.527 11.187 8.527L11.187 8.527Q9.819 8.419 8.883 8.491L8.883 8.491Q7.659 8.599 6.579 8.995L6.579 8.995Q4.995 9.535 3.879 10.831L3.879 10.831Q2.943 11.947 2.295 13.711L2.295 13.711Q2.079 14.395 1.647 15.943L1.647 15.943Q1.503 15.727 1.395 15.619L1.395 15.619Q1.179 15.403 1.179 15.187L1.179 15.187L1.035 15.259Q0.819 15.475 0.747 15.619L0.747 15.619L0.747 16.195Q0.747 16.627 0.963 17.095L0.963 17.095Q2.259 20.227 3.195 22.927L3.195 22.927Q3.555 23.611 4.203 23.611L4.203 23.611Q6.111 23.791 7.479 23.503L7.479 23.503L9.495 23.143Q9.063 22.711 8.847 22.603L8.847 22.603Q8.847 22.531 8.901 22.477Q8.955 22.423 8.955 22.351L8.955 22.351L10.503 22.711Q13.347 23.755 16.047 23.611L16.047 23.611Q16.659 23.611 16.803 23.143L16.803 23.143L17.163 22.495Q17.415 21.415 18.279 20.119L18.279 20.119L18.315 20.047Q18.711 19.507 18.855 19.363Q18.999 19.219 19.197 19.219Q19.395 19.219 19.863 19.363L19.863 19.363L20.187 19.435Q21.195 19.795 22.023 19.345Q22.851 18.895 23.103 17.851L23.103 17.851Q23.247 17.419 23.247 16.411ZM21.987 15.043L21.987 15.043Q21.663 15.403 21.555 15.403L21.555 15.403Q19.683 15.583 18.603 15.043L18.603 15.043Q18.351 14.971 17.955 14.539L17.955 14.539L17.703 14.287Q18.387 14.035 18.603 13.927L18.603 13.927Q20.007 13.783 21.447 14.503L21.447 14.503Q21.483 14.503 21.591 14.539L21.591 14.539L21.663 14.611Q21.987 14.935 21.987 15.043Z"/>',
|
|
572
578
|
'seti:java':
|
|
573
|
-
'<path d="
|
|
579
|
+
'<path d="M19.896 0.198L19.896 14.940Q19.854 15.108 19.854 15.444L19.854 15.444Q19.854 16.410 19.812 16.914L19.812 16.914Q19.728 17.796 19.518 18.384L19.518 18.384Q18.972 20.106 17.733 21.387Q16.494 22.668 14.856 23.340L14.856 23.340Q14.100 23.634 13.365 23.718Q12.630 23.802 11.454 23.802L11.454 23.802Q9.060 23.802 7.338 23.130L7.338 23.130Q5.448 22.248 4.104 20.610L4.104 20.610L6.750 17.208Q7.548 18.258 8.745 18.846Q9.942 19.434 11.328 19.434L11.328 19.434Q13.176 19.434 14.205 18.216Q15.234 16.998 15.234 14.562L15.234 14.562L15.234 0.198L19.896 0.198Z"/>',
|
|
574
580
|
'seti:javascript':
|
|
575
581
|
'<path d="M5.376 14.300L5.376 3.352L9.286 3.352L9.286 14.300Q9.286 17.842 7.630 19.452L7.630 19.452Q6.112 20.924 3.076 20.924L3.076 20.924Q2.386 20.924 1.558 20.809Q0.730 20.694 0.224 20.464L0.224 20.464L0.638 17.336Q1.512 17.750 2.662 17.750L2.662 17.750Q3.950 17.750 4.594 17.060L4.594 17.060Q5.376 16.232 5.376 14.300L5.376 14.300ZM11.862 19.912L12.736 16.600Q13.564 17.060 14.668 17.382L14.668 17.382Q15.910 17.750 17.014 17.750L17.014 17.750Q18.394 17.750 19.084 17.267Q19.774 16.784 19.774 15.910Q19.774 15.036 19.130 14.507Q18.486 13.978 16.876 13.426L16.876 13.426Q12.138 11.770 12.138 8.274L12.138 8.274Q12.138 5.974 13.909 4.525Q15.680 3.076 18.762 3.076L18.762 3.076Q21.200 3.076 23.224 3.950L23.224 3.950L22.350 7.124L22.074 6.986Q21.246 6.664 20.740 6.526L20.740 6.526Q19.774 6.250 18.762 6.250L18.762 6.250Q17.520 6.250 16.853 6.733Q16.186 7.216 16.186 7.998Q16.186 8.780 16.922 9.286L16.922 9.286Q17.474 9.700 19.314 10.436L19.314 10.436Q21.614 11.310 22.695 12.552Q23.776 13.794 23.776 15.588L23.776 15.588Q23.776 17.888 22.028 19.314L22.028 19.314Q20.142 20.924 16.738 20.924L16.738 20.924Q15.404 20.924 13.932 20.556L13.932 20.556Q12.782 20.326 11.862 19.912L11.862 19.912Z"/>',
|
|
576
582
|
'seti:jinja':
|
|
@@ -670,7 +676,7 @@ export const FileIcons = {
|
|
|
670
676
|
'seti:db':
|
|
671
677
|
'<path d="M12.546 9.327L12.546 9.327Q9.858 9.327 7.884 9.201L7.884 9.201Q5.448 9.033 3.348 8.571L3.348 8.571Q2.844 8.487 1.920 8.109L1.920 8.109Q1.416 7.857 1.122 7.773L1.122 7.773Q0.576 7.605 0.576 6.975L0.576 6.975L0.576 2.397Q0.576 2.187 0.681 2.019Q0.786 1.851 0.954 1.851L0.954 1.851L1.374 1.683Q2.802 1.053 3.600 0.927L3.600 0.927Q5.784 0.423 8.472 0.255L8.472 0.255Q10.068 0.171 13.302 0.171L13.302 0.171Q17.712 0.171 21.198 1.095L21.198 1.095Q21.996 1.263 22.878 1.725L22.878 1.725Q23.424 1.893 23.424 2.523L23.424 2.523L23.424 7.101Q23.424 7.395 23.046 7.773L23.046 7.773Q21.996 8.277 21.450 8.445L21.450 8.445L19.602 8.739Q17.166 9.117 15.948 9.201L15.948 9.201Q15.360 9.285 14.205 9.285Q13.050 9.285 12.546 9.327ZM23.424 9.621L23.424 9.621L23.424 14.325Q23.424 14.535 23.193 14.766Q22.962 14.997 22.752 14.997L22.752 14.997L22.080 15.249Q20.820 15.669 20.274 15.795L20.274 15.795Q15.360 16.635 8.976 16.425L8.976 16.425L8.892 16.425Q6.792 16.299 5.700 16.173L5.700 16.173Q3.936 15.963 2.550 15.501L2.550 15.501Q2.004 15.375 0.996 14.871L0.996 14.871Q0.576 14.661 0.576 14.199L0.576 14.199L0.576 9.621Q3.180 10.503 6.288 10.839L6.288 10.839Q8.514 11.049 12 11.049L12 11.049Q15.150 11.175 17.712 10.881L17.712 10.881Q20.736 10.545 23.424 9.621ZM23.424 16.971L23.424 16.971L23.424 21.549Q23.424 21.759 23.193 21.990Q22.962 22.221 22.752 22.347L22.752 22.347Q21.702 22.725 21.198 22.893L21.198 22.893Q20.316 23.187 19.602 23.271L19.602 23.271Q11.580 24.447 3.726 23.145L3.726 23.145Q3.054 23.019 1.710 22.557L1.710 22.557L1.122 22.347Q0.828 22.263 0.702 22.053Q0.576 21.843 0.576 21.423L0.576 21.423L0.576 16.971Q3.096 17.853 6.204 18.189L6.204 18.189Q8.430 18.399 12 18.399L12 18.399Q15.486 18.399 17.712 18.189L17.712 18.189Q20.820 17.853 23.424 16.971Z"/>',
|
|
672
678
|
'seti:terraform':
|
|
673
|
-
'<path d="M8.
|
|
679
|
+
'<path d="M8.850 11.880L8.850 4.200L15.150 8.040L15.150 15.720L8.850 11.880ZM22.590 4.200L15.900 8.040L15.900 15.720L22.590 11.880L22.590 4.200ZM8.100 3.840L1.410 0.120L1.410 7.560L8.100 11.280L8.100 3.840ZM8.850 12.750L8.850 20.160L15.150 23.880L15.150 16.470L8.850 12.750Z"/>',
|
|
674
680
|
'seti:tex':
|
|
675
681
|
'<path d="M3.651 6.951L3.651 13.650L2.199 13.650L2.199 14.970L6.753 14.970L6.753 13.650L5.400 13.650L5.400 6.951L5.829 6.951Q6.456 6.951 6.753 7.017Q7.050 7.083 7.198 7.281Q7.347 7.479 7.479 7.974L7.479 7.974L8.700 7.974L8.502 5.598L0.450 5.598L0.153 9.327L1.374 9.327L1.374 8.799Q1.473 7.842 1.605 7.545L1.605 7.545Q1.770 7.149 2.100 7.050L2.100 7.050Q2.397 6.951 3.222 6.951L3.222 6.951L3.651 6.951ZM11.802 17.346L11.802 17.346L10.053 17.346L10.053 14.475L10.647 14.475Q11.076 14.475 11.191 14.508Q11.307 14.541 11.340 14.706Q11.373 14.871 11.373 15.399L11.373 15.399L11.373 15.927L12.627 15.927L12.627 11.670L11.373 11.670L11.373 12.198Q11.373 12.726 11.340 12.891Q11.307 13.056 11.191 13.089Q11.076 13.122 10.647 13.122L10.647 13.122L10.053 13.122L10.053 10.647L11.703 10.647Q12.462 10.647 12.809 10.812Q13.155 10.977 13.287 11.373L13.287 11.373Q13.386 11.703 13.452 12.495L13.452 12.495L14.673 12.495L14.376 9.195L7.149 9.195L7.149 10.548L8.172 10.548L8.172 17.148L7.149 17.148L7.149 18.501L14.475 18.501L14.871 15.795L13.551 15.795Q13.551 16.686 13.171 17.016Q12.792 17.346 11.802 17.346ZM17.874 14.970L17.874 13.749L17.379 13.749L18.897 11.472L20.448 13.749L20.151 13.749L20.151 14.871L23.847 14.871L23.847 13.650L23.352 13.650Q22.890 13.650 22.791 13.617Q22.692 13.584 22.626 13.452L22.626 13.452L20.151 9.822L21.801 7.446L21.900 7.347Q22.098 7.116 22.263 7.017L22.263 7.017Q22.527 6.852 22.923 6.852L22.923 6.852L23.451 6.852L23.451 5.499L20.250 5.499L20.250 6.720L20.778 6.720L20.679 6.852L19.425 8.601L18.072 6.951L18.402 6.951L18.402 5.499L14.673 5.499L14.673 6.951L15.201 6.951Q15.663 6.951 15.745 6.967Q15.828 6.984 15.927 7.149L15.927 7.149L18.072 10.350L16.224 13.122L15.927 13.452Q15.597 13.749 15.102 13.749L15.102 13.749L14.574 13.749L14.574 14.970L17.874 14.970Z"/>',
|
|
676
682
|
'seti:default':
|
|
@@ -683,6 +689,8 @@ export const FileIcons = {
|
|
|
683
689
|
'<path d="M1.668 0.198L1.668 0.198L22.332 0.198Q22.962 0.198 23.382 0.618Q23.802 1.038 23.802 1.668L23.802 1.668L23.802 22.332Q23.802 22.962 23.382 23.382Q22.962 23.802 22.332 23.802L22.332 23.802L1.668 23.802Q1.038 23.802 0.618 23.382Q0.198 22.962 0.198 22.332L0.198 22.332L0.198 1.668Q0.198 1.038 0.618 0.618Q1.038 0.198 1.668 0.198ZM10.572 12.546L13.470 12.546L13.470 10.530L5.364 10.530L5.364 12.546L8.262 12.546L8.262 21.576L10.572 21.576L10.572 12.546ZM14.268 19.140L14.268 21.702Q14.898 22.038 15.675 22.185Q16.452 22.332 17.313 22.332Q18.174 22.332 18.951 22.164Q19.728 21.996 20.337 21.576Q20.946 21.156 21.282 20.526Q21.618 19.896 21.618 18.930L21.618 18.930Q21.618 18.216 21.408 17.712Q21.198 17.208 20.820 16.788Q20.442 16.368 19.917 16.032Q19.392 15.696 18.804 15.444L18.804 15.444Q18.342 15.234 17.985 15.045Q17.628 14.856 17.355 14.667Q17.082 14.478 16.914 14.226Q16.746 13.974 16.746 13.701Q16.746 13.428 16.893 13.218Q17.040 13.008 17.271 12.861Q17.502 12.714 17.838 12.630Q18.174 12.546 18.594 12.546L18.594 12.546Q19.602 12.546 20.526 13.008L20.526 13.008Q20.862 13.134 21.114 13.344L21.114 13.344L21.114 10.950Q20.526 10.740 19.938 10.614L19.938 10.614Q19.182 10.530 18.426 10.530L18.426 10.530Q17.586 10.530 16.809 10.719Q16.032 10.908 15.465 11.328Q14.898 11.748 14.562 12.378Q14.226 13.008 14.226 13.932L14.226 13.932Q14.226 15.066 14.835 15.864Q15.444 16.662 16.704 17.208L16.704 17.208L17.628 17.628Q18.048 17.838 18.363 18.069Q18.678 18.300 18.867 18.573Q19.056 18.846 19.056 19.140L19.056 19.140Q19.056 19.686 18.594 19.980L18.594 19.980Q18.384 20.148 18.006 20.232Q17.628 20.316 17.208 20.316L17.208 20.316Q16.410 20.316 15.654 20.022Q14.898 19.728 14.268 19.140L14.268 19.140Z"/>',
|
|
684
690
|
'seti:vala':
|
|
685
691
|
'<path d="M13.452 8.241L13.490 8.241Q15.010 8.241 16.454 8.583L16.454 8.583L17.024 8.849Q18.050 9.343 18.278 10.255L18.278 10.255Q18.506 11.053 18.088 11.927L18.088 11.927Q17.974 12.307 17.670 12.725L17.670 12.725Q17.480 12.953 17.024 13.333L17.024 13.333L16.796 13.599Q16.112 14.169 14.592 15.157L14.592 15.157L13.718 15.727Q13.414 15.917 12.806 16.297L12.806 16.297Q11.704 17.019 11.210 17.513L11.210 17.513Q11.096 17.627 10.925 17.855Q10.754 18.083 10.602 18.197L10.602 18.197Q10.450 18.463 10.431 18.786Q10.412 19.109 10.488 19.413L10.488 19.413Q10.754 19.945 11.267 20.363Q11.780 20.781 12.445 20.952Q13.110 21.123 13.604 20.743Q14.098 20.363 14.174 19.641L14.174 19.641L14.174 19.147Q14.174 18.691 14.554 18.349L14.554 18.349Q15.162 17.893 15.846 17.741L15.846 17.741Q17.100 17.475 17.746 17.627L17.746 17.627Q17.974 17.627 18.088 17.741L18.088 17.741Q18.544 17.931 18.658 18.197Q18.772 18.463 18.696 18.919L18.696 18.919Q18.202 20.895 16.568 22.377L16.568 22.377Q15.124 23.631 13.338 23.783L13.338 23.783Q11.932 23.973 10.488 23.441L10.488 23.441Q5.814 21.655 4.218 16.791L4.218 16.791Q3.686 15.005 4.180 13.447Q4.674 11.889 6.118 10.749L6.118 10.749Q7.752 9.229 10.754 8.583L10.754 8.583Q11.704 8.355 12.160 8.355L12.160 8.355Q12.768 8.241 13.452 8.241L13.452 8.241ZM15.010 4.783L15.010 4.783Q15.200 1.933 17.518 0.641L17.518 0.641Q18.924-0.081 20.368 0.299L20.368 0.299Q21.166 0.451 21.470 0.907Q21.774 1.363 21.641 2.199Q21.508 3.035 20.824 3.966Q20.140 4.897 19.722 5.353L19.722 5.353Q19.038 6.075 18.354 6.455L18.354 6.455Q17.594 7.025 16.796 7.177L16.796 7.177Q16.226 7.253 15.827 7.063Q15.428 6.873 15.238 6.341L15.238 6.341Q15.010 5.619 15.010 4.783ZM13.338 2.769L13.338 2.769Q13.338 4.479 12.502 5.619L12.502 5.619Q12.350 5.961 12.046 6.113L12.046 6.113Q11.780 6.379 11.457 6.379Q11.134 6.379 10.868 6.113L10.868 6.113Q10.488 5.733 10.260 5.049L10.260 5.049Q9.842 3.605 10.146 2.427L10.146 2.427Q10.526 1.097 11.932 1.097L11.932 1.097Q12.388 1.097 12.711 1.287Q13.034 1.477 13.110 1.819L13.110 1.819Q13.224 1.933 13.224 2.199L13.224 2.199Q13.224 2.541 13.338 2.769ZM8.474 4.897L8.474 5.277Q8.474 5.847 8.436 6.151L8.436 6.151Q8.360 6.607 8.132 6.949L8.132 6.949Q7.942 7.405 7.600 7.462Q7.258 7.519 6.840 7.177L6.840 7.177Q5.814 6.341 5.624 5.049L5.624 5.049L5.624 4.213Q5.738 3.643 6.137 3.263Q6.536 2.883 7.068 2.883L7.068 2.883Q7.676 2.883 8.018 3.377L8.018 3.377Q8.474 4.023 8.474 4.897L8.474 4.897ZM5.168 8.735L5.168 8.697Q5.168 9.077 4.940 9.533L4.940 9.533Q4.750 10.065 4.218 9.913L4.218 9.913L4.104 9.875L3.990 9.799Q3.268 9.533 2.793 8.716Q2.318 7.899 2.318 7.177L2.318 7.177Q2.318 6.759 2.584 6.417Q2.850 6.075 3.268 5.847L3.268 5.847Q3.800 5.695 4.332 6.227L4.332 6.227Q4.636 6.531 4.788 7.025L4.788 7.025Q4.902 7.291 5.016 7.899L5.016 7.899L5.054 8.013Q5.168 8.355 5.168 8.735L5.168 8.735Z"/>',
|
|
692
|
+
'seti:vite':
|
|
693
|
+
'<path d="M16.232 0.179L16.232 0.179L6.392 2.139Q6.152 2.179 6.112 2.459L6.112 2.459L5.512 12.659Q5.512 12.859 5.652 12.979Q5.792 13.099 5.952 13.059L5.952 13.059L8.672 12.419Q8.872 12.379 9.012 12.519Q9.152 12.659 9.112 12.819L9.112 12.819L8.312 16.819Q8.272 17.019 8.432 17.159Q8.592 17.299 8.752 17.219L8.752 17.219L10.472 16.699Q10.672 16.659 10.812 16.799Q10.952 16.939 10.912 17.139L10.912 17.139L9.632 23.379Q9.552 23.699 9.832 23.799Q10.112 23.899 10.272 23.659L10.272 23.659L10.432 23.419L18.432 7.459Q18.552 7.259 18.412 7.079Q18.272 6.899 18.032 6.939L18.032 6.939L15.232 7.459Q15.032 7.499 14.892 7.359Q14.752 7.219 14.832 7.019L14.832 7.019L16.672 0.659Q16.712 0.459 16.572 0.299Q16.432 0.139 16.232 0.179Z"/>',
|
|
686
694
|
'seti:vue':
|
|
687
695
|
'<path d="M6.117 1.659L12.000 11.870L17.883 1.659L14.775 1.659L12.000 6.469L9.225 1.659L6.117 1.659ZM23.951 1.659L19.178 1.659L12.000 14.090L4.822 1.659L0.049 1.659L12.000 22.341L23.951 1.659Z"/>',
|
|
688
696
|
'seti:wasm':
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
|
|
4
|
+
const collectionNames = ['docs', 'i18n'] as const;
|
|
5
|
+
export type StarlightCollection = (typeof collectionNames)[number];
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* We still rely on the content collection folder structure to be fixed for now:
|
|
9
|
+
*
|
|
10
|
+
* - At build time, if the feature is enabled, we get all the last commit dates for each file in
|
|
11
|
+
* the docs folder ahead of time. In the current approach, we cannot know at this time the
|
|
12
|
+
* user-defined content folder path in the integration context as this would only be available
|
|
13
|
+
* from the loader. A potential solution could be to do that from a custom loader re-implementing
|
|
14
|
+
* the glob loader or built on top of it. Although, we don't have access to the Starlight
|
|
15
|
+
* configuration from the loader to even know we should do that.
|
|
16
|
+
* - Remark plugins get passed down an absolute path to a content file and we need to figure out
|
|
17
|
+
* the language from that path. Without knowing the content folder path, we cannot reliably do
|
|
18
|
+
* so.
|
|
19
|
+
*
|
|
20
|
+
* Below are various functions to easily get paths to these collections and avoid having to
|
|
21
|
+
* hardcode them throughout the codebase. When user-defined content folder locations are supported,
|
|
22
|
+
* these helper functions should be updated to reflect that in one place.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
export function getCollectionPath(collection: StarlightCollection, srcDir: URL) {
|
|
26
|
+
return new URL(`content/${collection}/`, srcDir).pathname;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function resolveCollectionPath(collection: StarlightCollection, srcDir: URL) {
|
|
30
|
+
return resolve(fileURLToPath(srcDir), `content/${collection}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function getCollectionPathFromRoot(
|
|
34
|
+
collection: StarlightCollection,
|
|
35
|
+
{ root, srcDir }: { root: URL | string; srcDir: URL | string }
|
|
36
|
+
) {
|
|
37
|
+
return (
|
|
38
|
+
(typeof srcDir === 'string' ? srcDir : srcDir.pathname).replace(
|
|
39
|
+
typeof root === 'string' ? root : root.pathname,
|
|
40
|
+
''
|
|
41
|
+
) +
|
|
42
|
+
'content/' +
|
|
43
|
+
collection
|
|
44
|
+
);
|
|
45
|
+
}
|
package/utils/git.ts
CHANGED
|
@@ -55,8 +55,8 @@ function getRepoRoot(directory: string): string {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
export function getAllNewestCommitDate(
|
|
59
|
-
const repoRoot = getRepoRoot(
|
|
58
|
+
export function getAllNewestCommitDate(rootPath: string, docsPath: string): [string, number][] {
|
|
59
|
+
const repoRoot = getRepoRoot(docsPath);
|
|
60
60
|
|
|
61
61
|
const gitLog = spawnSync(
|
|
62
62
|
'git',
|
|
@@ -67,7 +67,7 @@ export function getAllNewestCommitDate(directory: string): [string, number][] {
|
|
|
67
67
|
// In each entry include the name and status for each modified file
|
|
68
68
|
'--name-status',
|
|
69
69
|
'--',
|
|
70
|
-
|
|
70
|
+
docsPath,
|
|
71
71
|
],
|
|
72
72
|
{
|
|
73
73
|
cwd: repoRoot,
|
|
@@ -105,7 +105,9 @@ export function getAllNewestCommitDate(directory: string): [string, number][] {
|
|
|
105
105
|
|
|
106
106
|
return Array.from(latestDates.entries()).map(([file, date]) => {
|
|
107
107
|
const fileFullPath = resolve(repoRoot, file);
|
|
108
|
-
|
|
108
|
+
let fileInDirectory = relative(rootPath, fileFullPath);
|
|
109
|
+
// Format path to unix style path.
|
|
110
|
+
fileInDirectory = fileInDirectory?.replace(/\\/g, '/');
|
|
109
111
|
|
|
110
112
|
return [fileInDirectory, date];
|
|
111
113
|
});
|
package/utils/navigation.ts
CHANGED
|
@@ -205,8 +205,8 @@ function pathsMatch(pathA: string, pathB: string) {
|
|
|
205
205
|
function getBreadcrumbs(path: string, baseDir: string): string[] {
|
|
206
206
|
// Strip extension from path.
|
|
207
207
|
const pathWithoutExt = stripExtension(path);
|
|
208
|
-
// Index paths will match `baseDir`
|
|
209
|
-
if (pathWithoutExt === baseDir) return [];
|
|
208
|
+
// Index paths will match `baseDir` but we still need to consider them as a single segment.
|
|
209
|
+
if (pathWithoutExt === baseDir) return [path];
|
|
210
210
|
// Ensure base directory ends in a trailing slash.
|
|
211
211
|
baseDir = ensureTrailingSlash(baseDir);
|
|
212
212
|
// Strip base directory from path if present.
|
package/utils/plugins.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type { AstroIntegration, HookParameters } from 'astro';
|
|
|
2
2
|
import { z } from 'astro/zod';
|
|
3
3
|
import { StarlightConfigSchema, type StarlightUserConfig } from '../utils/user-config';
|
|
4
4
|
import { parseWithFriendlyErrors } from '../utils/error-map';
|
|
5
|
-
import { AstroError } from 'astro/errors';
|
|
6
5
|
import type { UserI18nSchema } from './translations';
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -83,14 +82,6 @@ export async function runPlugins(
|
|
|
83
82
|
});
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
if (context.config.output === 'static' && !starlightConfig.prerender) {
|
|
87
|
-
throw new AstroError(
|
|
88
|
-
'Starlight’s `prerender: false` option requires `output: "hybrid"` or `"server"` in your Astro config.',
|
|
89
|
-
'Either set `output` in your Astro config or set `prerender: true` in the Starlight options.\n\n' +
|
|
90
|
-
'Learn more about rendering modes in the Astro docs: https://docs.astro.build/en/basics/rendering-modes/'
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
85
|
return { integrations, starlightConfig, pluginTranslations };
|
|
95
86
|
}
|
|
96
87
|
|
package/utils/route-data.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import type { MarkdownHeading } from 'astro';
|
|
2
|
-
import project from 'virtual:starlight/project-context';
|
|
3
2
|
import config from 'virtual:starlight/user-config';
|
|
4
3
|
import { generateToC, type TocItem } from './generateToC';
|
|
5
4
|
import { getNewestCommitDate } from 'virtual:starlight/git-info';
|
|
6
5
|
import { getPrevNextLinks, getSidebar, type SidebarEntry } from './navigation';
|
|
7
6
|
import { ensureTrailingSlash } from './path';
|
|
8
7
|
import type { Route } from './routing';
|
|
9
|
-
import { localizedId } from './slugs';
|
|
10
8
|
import { formatPath } from './format-path';
|
|
11
9
|
import { useTranslations } from './translations';
|
|
12
10
|
import { DeprecatedLabelsPropProxy } from './i18n';
|
|
@@ -85,7 +83,7 @@ function getLastUpdated({ entry }: PageProps): Date | undefined {
|
|
|
85
83
|
try {
|
|
86
84
|
return frontmatterLastUpdated instanceof Date
|
|
87
85
|
? frontmatterLastUpdated
|
|
88
|
-
: getNewestCommitDate(entry.
|
|
86
|
+
: getNewestCommitDate(entry.filePath);
|
|
89
87
|
} catch {
|
|
90
88
|
// If the git command fails, ignore the error.
|
|
91
89
|
return undefined;
|
|
@@ -95,7 +93,7 @@ function getLastUpdated({ entry }: PageProps): Date | undefined {
|
|
|
95
93
|
return undefined;
|
|
96
94
|
}
|
|
97
95
|
|
|
98
|
-
function getEditUrl({ entry
|
|
96
|
+
function getEditUrl({ entry }: PageProps): URL | undefined {
|
|
99
97
|
const { editUrl } = entry.data;
|
|
100
98
|
// If frontmatter value is false, editing is disabled for this page.
|
|
101
99
|
if (editUrl === false) return;
|
|
@@ -105,10 +103,8 @@ function getEditUrl({ entry, id, isFallback }: PageProps): URL | undefined {
|
|
|
105
103
|
// If a URL was provided in frontmatter, use that.
|
|
106
104
|
url = editUrl;
|
|
107
105
|
} else if (config.editLink.baseUrl) {
|
|
108
|
-
const srcPath = project.srcDir.replace(project.root, '');
|
|
109
|
-
const filePath = isFallback ? localizedId(id, config.defaultLocale.locale) : id;
|
|
110
106
|
// If a base URL was added in Starlight config, synthesize the edit URL from it.
|
|
111
|
-
url = ensureTrailingSlash(config.editLink.baseUrl) +
|
|
107
|
+
url = ensureTrailingSlash(config.editLink.baseUrl) + entry.filePath;
|
|
112
108
|
}
|
|
113
109
|
return url ? new URL(url) : undefined;
|
|
114
110
|
}
|
package/utils/routing.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { GetStaticPathsItem } from 'astro';
|
|
2
2
|
import { type CollectionEntry, getCollection } from 'astro:content';
|
|
3
3
|
import config from 'virtual:starlight/user-config';
|
|
4
|
+
import project from 'virtual:starlight/project-context';
|
|
5
|
+
import { getCollectionPathFromRoot } from './collection';
|
|
4
6
|
import {
|
|
5
7
|
type LocaleData,
|
|
6
8
|
localizedId,
|
|
@@ -15,7 +17,22 @@ import { BuiltInDefaultLocale } from './i18n';
|
|
|
15
17
|
// We do this here so all pages trigger it and at the top level so it runs just once.
|
|
16
18
|
validateLogoImports();
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
// The type returned from `CollectionEntry` is different for legacy collections and collections
|
|
21
|
+
// using a loader. This type is a common subset of both types.
|
|
22
|
+
export type StarlightDocsCollectionEntry = Omit<
|
|
23
|
+
CollectionEntry<'docs'>,
|
|
24
|
+
'id' | 'filePath' | 'render' | 'slug'
|
|
25
|
+
> & {
|
|
26
|
+
// Update the `id` property to be a string like in the loader type.
|
|
27
|
+
id: string;
|
|
28
|
+
// Add the `filePath` property which is only present in the loader type.
|
|
29
|
+
filePath?: string;
|
|
30
|
+
// Add the `slug` property which is only present in the legacy type.
|
|
31
|
+
slug?: string;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type StarlightDocsEntry = StarlightDocsCollectionEntry & {
|
|
35
|
+
filePath: string;
|
|
19
36
|
slug: string;
|
|
20
37
|
};
|
|
21
38
|
|
|
@@ -24,9 +41,9 @@ export interface Route extends LocaleData {
|
|
|
24
41
|
entry: StarlightDocsEntry;
|
|
25
42
|
/** Locale metadata for the page content. Can be different from top-level locale values when a page is using fallback content. */
|
|
26
43
|
entryMeta: LocaleData;
|
|
27
|
-
/**
|
|
44
|
+
/** @deprecated Migrate to the new Content Layer API and use `id` instead. */
|
|
28
45
|
slug: string;
|
|
29
|
-
/** The unique ID
|
|
46
|
+
/** The slug or unique ID if using the `legacy.collections` flag. */
|
|
30
47
|
id: string;
|
|
31
48
|
/** True if this page is untranslated in the current language and using fallback content from the default locale. */
|
|
32
49
|
isFallback?: true;
|
|
@@ -45,16 +62,27 @@ interface Path extends GetStaticPathsItem {
|
|
|
45
62
|
*/
|
|
46
63
|
const normalizeIndexSlug = (slug: string) => (slug === 'index' ? '' : slug);
|
|
47
64
|
|
|
65
|
+
/** Normalize the different collection entry we can get from a legacy collection or a loader. */
|
|
66
|
+
export function normalizeCollectionEntry(entry: StarlightDocsCollectionEntry): StarlightDocsEntry {
|
|
67
|
+
const slug = normalizeIndexSlug(entry.slug ?? entry.id);
|
|
68
|
+
return {
|
|
69
|
+
...entry,
|
|
70
|
+
// In a collection with a loader, the `id` is a slug and should be normalized.
|
|
71
|
+
id: entry.slug ? entry.id : slug,
|
|
72
|
+
// In a legacy collection, the `filePath` property doesn't exist.
|
|
73
|
+
filePath: entry.filePath ?? `${getCollectionPathFromRoot('docs', project)}/${entry.id}`,
|
|
74
|
+
// In a collection with a loader, the `slug` property is replaced by the `id`.
|
|
75
|
+
slug: normalizeIndexSlug(entry.slug ?? entry.id),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
48
79
|
/** All entries in the docs content collection. */
|
|
49
80
|
const docs: StarlightDocsEntry[] = (
|
|
50
81
|
(await getCollection('docs', ({ data }) => {
|
|
51
82
|
// In production, filter out drafts.
|
|
52
83
|
return import.meta.env.MODE !== 'production' || data.draft === false;
|
|
53
84
|
})) ?? []
|
|
54
|
-
).map(
|
|
55
|
-
...entry,
|
|
56
|
-
slug: normalizeIndexSlug(slug),
|
|
57
|
-
}));
|
|
85
|
+
).map(normalizeCollectionEntry);
|
|
58
86
|
|
|
59
87
|
function getRoutes(): Route[] {
|
|
60
88
|
const routes: Route[] = docs.map((entry) => ({
|
|
@@ -79,7 +107,7 @@ function getRoutes(): Route[] {
|
|
|
79
107
|
const localeDocs = getLocaleDocs(locale);
|
|
80
108
|
for (const fallback of defaultLocaleDocs) {
|
|
81
109
|
const slug = localizedSlug(fallback.slug, locale);
|
|
82
|
-
const id = localizedId(fallback.id, locale);
|
|
110
|
+
const id = project.legacyCollections ? localizedId(fallback.id, locale) : slug;
|
|
83
111
|
const doesNotNeedFallback = localeDocs.some((doc) => doc.slug === slug);
|
|
84
112
|
if (doesNotNeedFallback) continue;
|
|
85
113
|
routes.push({
|
package/utils/slugs.ts
CHANGED
|
@@ -82,7 +82,7 @@ export function localizedSlug(slug: string, locale: string | undefined): string
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
|
-
* Convert a collection entry ID to a different locale.
|
|
85
|
+
* Convert a legacy collection entry ID to a different locale.
|
|
86
86
|
* For example, passing an ID of `en/home.md` and a locale of `fr` results in `fr/home.md`.
|
|
87
87
|
* An undefined locale is treated as the root locale, resulting in `home.md`.
|
|
88
88
|
* @param id A collection entry ID
|
package/utils/starlight-page.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { z } from 'astro/zod';
|
|
2
2
|
import { type ContentConfig, type SchemaContext } from 'astro:content';
|
|
3
|
+
import project from 'virtual:starlight/project-context';
|
|
3
4
|
import config from 'virtual:starlight/user-config';
|
|
5
|
+
import { getCollectionPathFromRoot } from './collection';
|
|
4
6
|
import { parseWithFriendlyErrors, parseAsyncWithFriendlyErrors } from './error-map';
|
|
5
7
|
import { stripLeadingAndTrailingSlashes } from './path';
|
|
6
8
|
import {
|
|
@@ -97,8 +99,8 @@ export type StarlightPageProps = Prettify<
|
|
|
97
99
|
*/
|
|
98
100
|
type StarlightPageDocsEntry = Omit<StarlightDocsEntry, 'id' | 'render'> & {
|
|
99
101
|
/**
|
|
100
|
-
* The unique ID for this Starlight page which cannot be
|
|
101
|
-
* collection entries.
|
|
102
|
+
* The unique ID if using the `legacy.collections` for this Starlight page which cannot be
|
|
103
|
+
* inferred from codegen like content collection entries or the slug.
|
|
102
104
|
*/
|
|
103
105
|
id: string;
|
|
104
106
|
};
|
|
@@ -113,7 +115,7 @@ export async function generateStarlightPageRouteData({
|
|
|
113
115
|
const { isFallback, frontmatter, ...routeProps } = props;
|
|
114
116
|
const slug = urlToSlug(url);
|
|
115
117
|
const pageFrontmatter = await getStarlightPageFrontmatter(frontmatter);
|
|
116
|
-
const id = `${stripLeadingAndTrailingSlashes(slug)}.md
|
|
118
|
+
const id = project.legacyCollections ? `${stripLeadingAndTrailingSlashes(slug)}.md` : slug;
|
|
117
119
|
const localeData = slugToLocaleData(slug);
|
|
118
120
|
const sidebar = props.sidebar
|
|
119
121
|
? getSidebarFromConfig(validateSidebarProp(props.sidebar), url.pathname, localeData.locale)
|
|
@@ -124,6 +126,7 @@ export async function generateStarlightPageRouteData({
|
|
|
124
126
|
slug,
|
|
125
127
|
body: '',
|
|
126
128
|
collection: 'docs',
|
|
129
|
+
filePath: `${getCollectionPathFromRoot('docs', project)}/${stripLeadingAndTrailingSlashes(slug)}.md`,
|
|
127
130
|
data: {
|
|
128
131
|
...pageFrontmatter,
|
|
129
132
|
sidebar: {
|
package/virtual-internal.d.ts
CHANGED
|
File without changes
|