@astrojs/starlight 0.40.0 → 0.41.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 +22 -0
- package/index.ts +10 -9
- package/integrations/anchor-icon.ts +2 -2
- package/integrations/markdown-plugins.ts +30 -27
- package/integrations/{markdown-process.ts → markdown-processor.ts} +14 -2
- package/integrations/{code-rtl-support.ts → rehype-code-rtl-support.ts} +1 -1
- package/integrations/{heading-links.ts → rehype-heading-links.ts} +1 -1
- package/integrations/{asides.ts → remark-asides.ts} +1 -1
- package/integrations/remark-rehype.ts +10 -5
- package/integrations/satteri.ts +2 -6
- package/integrations/vite-lazy-barrel-optimization.ts +40 -0
- package/integrations/{virtual-user-config.ts → vite-virtual-modules.ts} +1 -1
- package/package.json +9 -9
- package/user-components/Badge.astro +1 -6
- package/user-components/Icon.astro +9 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @astrojs/starlight
|
|
2
2
|
|
|
3
|
+
## 0.41.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#3951](https://github.com/withastro/starlight/pull/3951) [`1202dd4`](https://github.com/withastro/starlight/commit/1202dd4c3efd517bdfe213eaf84262e439485e45) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Adds support for Astro v7, drops support for Astro v6.
|
|
8
|
+
|
|
9
|
+
#### Upgrade Astro and dependencies
|
|
10
|
+
|
|
11
|
+
⚠️ **BREAKING CHANGE:** Astro v6 is no longer supported. Make sure you [update Astro](https://docs.astro.build/en/guides/upgrade-to/v7/) 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 v7. 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
|
+
⚠️ **BREAKING CHANGE:** This release drops official support for Chromium-based browsers prior to version 111 (released 07 March 2023) and Safari-based browsers prior to version 16.4 (released 27 March 2023). You can find a list of currently supported browsers and their versions using this [browserslist query](https://browsersl.ist/#q=%3E+0.5%25%2C+not+dead%2C+Chrome+%3E%3D+111%2C+Edge+%3E%3D+111%2C+Firefox+%3E%3D+121%2C+Safari+%3E%3D+16.4%2C+iOS+%3E%3D+16.4%2C+not+op_mini+all).
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [#3953](https://github.com/withastro/starlight/pull/3953) [`a935d33`](https://github.com/withastro/starlight/commit/a935d334c193fb452f72453ea1bf38807d415077) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes Starlight Markdown processing being potentially applied to files that should not be processed.
|
|
24
|
+
|
|
3
25
|
## 0.40.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
package/index.ts
CHANGED
|
@@ -10,17 +10,18 @@
|
|
|
10
10
|
import mdx from '@astrojs/mdx';
|
|
11
11
|
import type { AstroIntegration } from 'astro';
|
|
12
12
|
import { AstroError } from 'astro/errors';
|
|
13
|
-
import type { MarkdownProcessorPluginOptions } from './integrations/markdown-
|
|
13
|
+
import type { MarkdownProcessorPluginOptions } from './integrations/markdown-processor';
|
|
14
14
|
import {
|
|
15
15
|
applyStarlightMarkdownPlugins,
|
|
16
|
-
satteriIntegration,
|
|
17
16
|
starlightDirectivesRestorationIntegration,
|
|
17
|
+
unifiedIntegration,
|
|
18
18
|
} from './integrations/markdown-plugins';
|
|
19
19
|
import { starlightExpressiveCode } from './integrations/expressive-code/index';
|
|
20
20
|
import { starlightPagefind } from './integrations/pagefind';
|
|
21
21
|
import { starlightSitemap } from './integrations/sitemap';
|
|
22
22
|
import { vitePluginStarlightCssLayerOrder } from './integrations/vite-layer-order';
|
|
23
|
-
import {
|
|
23
|
+
import { vitePluginStarlightLazyBarrelOptimization } from './integrations/vite-lazy-barrel-optimization';
|
|
24
|
+
import { vitePluginStarlightVirtualModules } from './integrations/vite-virtual-modules';
|
|
24
25
|
import {
|
|
25
26
|
injectPluginTranslationsTypes,
|
|
26
27
|
runPlugins,
|
|
@@ -90,11 +91,10 @@ export default function StarlightIntegration(
|
|
|
90
91
|
prerender: starlightConfig.prerender,
|
|
91
92
|
});
|
|
92
93
|
|
|
93
|
-
//
|
|
94
|
-
//
|
|
95
|
-
// usage before wiring up the integrations below.
|
|
94
|
+
// Resolve the configured processor and the optional Unified integration up front before
|
|
95
|
+
// wiring up the integrations below.
|
|
96
96
|
const processor = config.markdown.processor;
|
|
97
|
-
const
|
|
97
|
+
const unified = await unifiedIntegration;
|
|
98
98
|
|
|
99
99
|
// Add built-in integrations only if they are not already added by the user through the
|
|
100
100
|
// config or by a plugin.
|
|
@@ -119,7 +119,7 @@ export default function StarlightIntegration(
|
|
|
119
119
|
};
|
|
120
120
|
|
|
121
121
|
// We push our plugins onto the processor's options.
|
|
122
|
-
applyStarlightMarkdownPlugins(processor, markdownProcessorOptions,
|
|
122
|
+
applyStarlightMarkdownPlugins(processor, markdownProcessorOptions, unified, logger);
|
|
123
123
|
|
|
124
124
|
// Add Starlight directives restoration integration at the end of the list so that
|
|
125
125
|
// remark/mdast plugins injected by Starlight plugins through Astro integrations can
|
|
@@ -145,7 +145,8 @@ export default function StarlightIntegration(
|
|
|
145
145
|
vite: {
|
|
146
146
|
plugins: [
|
|
147
147
|
vitePluginStarlightCssLayerOrder(),
|
|
148
|
-
|
|
148
|
+
vitePluginStarlightLazyBarrelOptimization(),
|
|
149
|
+
vitePluginStarlightVirtualModules(
|
|
149
150
|
{ command, isNodeCompatibleEnv },
|
|
150
151
|
starlightConfig,
|
|
151
152
|
config,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SVG `d` for the anchor-link icon rendered next to headings. Shared by the unified
|
|
2
|
-
// (`heading-links.ts`) and Sätteri (`satteri.ts`) autolink plugins and the
|
|
3
|
-
// component so the three stay in sync.
|
|
2
|
+
// (`rehype-heading-links.ts`) and Sätteri (`satteri.ts`) autolink plugins and the
|
|
3
|
+
// `<AnchorHeading>` component so the three stay in sync.
|
|
4
4
|
export const anchorLinkIconPath =
|
|
5
5
|
'm12.11 15.39-3.88 3.88a2.52 2.52 0 0 1-3.5 0 2.47 2.47 0 0 1 0-3.5l3.88-3.88a1 1 0 0 0-1.42-1.42l-3.88 3.89a4.48 4.48 0 0 0 6.33 6.33l3.89-3.88a1 1 0 1 0-1.42-1.42Zm8.58-12.08a4.49 4.49 0 0 0-6.33 0l-3.89 3.88a1 1 0 0 0 1.42 1.42l3.88-3.88a2.52 2.52 0 0 1 3.5 0 2.47 2.47 0 0 1 0 3.5l-3.88 3.88a1 1 0 1 0 1.42 1.42l3.88-3.89a4.49 4.49 0 0 0 0-6.33ZM8.83 15.17a1 1 0 0 0 1.1.22 1 1 0 0 0 .32-.22l4.92-4.92a1 1 0 0 0-1.42-1.42l-4.92 4.92a1 1 0 0 0 0 1.42Z';
|
|
@@ -1,53 +1,56 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isSatteriProcessor } from '@astrojs/markdown-satteri';
|
|
2
2
|
import type { AstroConfig, AstroIntegration, AstroIntegrationLogger } from 'astro';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { starlightRehypePlugins, starlightRemarkPlugins } from './remark-rehype';
|
|
3
|
+
import type { MarkdownProcessorPluginOptions } from './markdown-processor';
|
|
4
|
+
import { satteriDirectivesRestoration, starlightSatteriPlugins } from './satteri';
|
|
6
5
|
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
|
|
6
|
+
// This file is imported by the Starlight integration that is used in Astro configuration files.
|
|
7
|
+
// When using Starlight, Astro loads its configuration using a temporary Vite module runner and
|
|
8
|
+
// closes it before running integration hooks. If this dynamic import is started later from an
|
|
9
|
+
// integration hook, Vite tries to resolve it through that closed runner and throw "Vite module
|
|
10
|
+
// runner has been closed".
|
|
11
|
+
// We start loading `./remark-rehype` at the top level so Vite waits for it to resolve or fail
|
|
12
|
+
// while the config runner is still running. This keeps the Unified integration optional as when
|
|
13
|
+
// `@astrojs/markdown-remark` is not installed, importing `./remark-rehype` rejects and we resolve
|
|
14
|
+
// it to `null`, which is later used to detect if Unified support is available or not.
|
|
15
|
+
export const unifiedIntegration = import('./remark-rehype').catch(() => null);
|
|
10
16
|
|
|
11
|
-
type
|
|
17
|
+
type UnifiedIntegration = Awaited<typeof unifiedIntegration>;
|
|
12
18
|
type MarkdownProcessor = NonNullable<AstroConfig['markdown']['processor']>;
|
|
13
19
|
|
|
14
|
-
/**
|
|
15
|
-
* Registers Starlight's Markdown transforms on the Astro 6.4+ `markdown.processor`, picking the
|
|
16
|
-
* plugin set for the configured engine.
|
|
17
|
-
*/
|
|
20
|
+
/** Registers Starlight's Markdown transforms, picking the plugin set for the configured engine. */
|
|
18
21
|
export function applyStarlightMarkdownPlugins(
|
|
19
22
|
processor: MarkdownProcessor,
|
|
20
23
|
options: MarkdownProcessorPluginOptions,
|
|
21
|
-
|
|
24
|
+
unified: UnifiedIntegration,
|
|
22
25
|
logger: Pick<AstroIntegrationLogger, 'warn'>
|
|
23
26
|
) {
|
|
24
|
-
if (
|
|
27
|
+
if (isSatteriProcessor(processor)) {
|
|
25
28
|
// Starlight's asides are built on container directives, which Sätteri disables by default.
|
|
26
29
|
processor.options.features.directive = true;
|
|
27
|
-
const { mdastPlugins, hastPlugins } =
|
|
30
|
+
const { mdastPlugins, hastPlugins } = starlightSatteriPlugins(options);
|
|
28
31
|
processor.options.mdastPlugins.push(...mdastPlugins);
|
|
29
32
|
processor.options.hastPlugins.push(...hastPlugins);
|
|
30
|
-
} else if (isUnifiedProcessor(processor)) {
|
|
31
|
-
processor.options.remarkPlugins.push(...starlightRemarkPlugins(options));
|
|
32
|
-
processor.options.rehypePlugins.push(...starlightRehypePlugins(options));
|
|
33
|
+
} else if (unified?.isUnifiedProcessor(processor)) {
|
|
34
|
+
processor.options.remarkPlugins.push(...unified.starlightRemarkPlugins(options));
|
|
35
|
+
processor.options.rehypePlugins.push(...unified.starlightRehypePlugins(options));
|
|
33
36
|
} else {
|
|
34
37
|
logger.warn(
|
|
35
38
|
`The configured \`markdown.processor\` ("${processor.name}") is not supported by Starlight. ` +
|
|
36
39
|
"Starlight's Markdown transforms (asides, heading anchor links, RTL code support) won't run on your content. " +
|
|
37
|
-
'Switch to `
|
|
40
|
+
'Switch to `satteri()` from `@astrojs/markdown-satteri` or `unified()` from `@astrojs/markdown-remark`.'
|
|
38
41
|
);
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
/** Registers the directive-restoration plugin
|
|
45
|
+
/** Registers the directive-restoration plugin. */
|
|
43
46
|
export function registerDirectivesRestoration(
|
|
44
47
|
processor: MarkdownProcessor,
|
|
45
|
-
|
|
48
|
+
unified: UnifiedIntegration
|
|
46
49
|
) {
|
|
47
|
-
if (
|
|
48
|
-
processor.options.mdastPlugins.push(
|
|
49
|
-
} else if (isUnifiedProcessor(processor)) {
|
|
50
|
-
processor.options.remarkPlugins.push(remarkDirectivesRestoration);
|
|
50
|
+
if (isSatteriProcessor(processor)) {
|
|
51
|
+
processor.options.mdastPlugins.push(satteriDirectivesRestoration());
|
|
52
|
+
} else if (unified?.isUnifiedProcessor(processor)) {
|
|
53
|
+
processor.options.remarkPlugins.push(unified.remarkDirectivesRestoration);
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
|
|
@@ -60,8 +63,8 @@ export function starlightDirectivesRestorationIntegration(): AstroIntegration {
|
|
|
60
63
|
name: 'starlight-directives-restoration',
|
|
61
64
|
hooks: {
|
|
62
65
|
'astro:config:setup': async ({ config }) => {
|
|
63
|
-
const
|
|
64
|
-
registerDirectivesRestoration(config.markdown?.processor,
|
|
66
|
+
const unified = await unifiedIntegration;
|
|
67
|
+
registerDirectivesRestoration(config.markdown?.processor, unified);
|
|
65
68
|
},
|
|
66
69
|
},
|
|
67
70
|
};
|
|
@@ -2,6 +2,7 @@ import { resolve } from 'node:path';
|
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import type { AstroConfig } from 'astro';
|
|
4
4
|
import { resolveCollectionPath } from '../utils/collection-fs';
|
|
5
|
+
import { ensureTrailingSlash } from '../utils/path';
|
|
5
6
|
import type { HookParameters, StarlightConfig } from '../types';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -21,10 +22,12 @@ export interface MarkdownProcessorPluginOptions {
|
|
|
21
22
|
* utility to determine if a file should be transformed by a plugin or not.
|
|
22
23
|
*/
|
|
23
24
|
export function getMarkdownProcessorPaths(options: MarkdownProcessorPluginOptions): string[] {
|
|
24
|
-
const paths = [
|
|
25
|
+
const paths = [normalizeDirectoryPath(resolveCollectionPath('docs', options.astroConfig.srcDir))];
|
|
25
26
|
|
|
26
27
|
for (const processedDir of options.starlightConfig.markdown.processedDirs) {
|
|
27
|
-
paths.push(
|
|
28
|
+
paths.push(
|
|
29
|
+
normalizeDirectoryPath(resolve(fileURLToPath(options.astroConfig.root), processedDir))
|
|
30
|
+
);
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
return paths;
|
|
@@ -50,3 +53,12 @@ const backSlashRegex = /\\/g;
|
|
|
50
53
|
function normalizePath(path: string) {
|
|
51
54
|
return path.replace(backSlashRegex, '/');
|
|
52
55
|
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Allowed paths are directory prefixes compared with `startsWith()` in {@link shouldTransformPath},
|
|
59
|
+
* so we ensure they have a trailing slash to avoid matching sibling directories with the same
|
|
60
|
+
* prefix.
|
|
61
|
+
*/
|
|
62
|
+
function normalizeDirectoryPath(path: string) {
|
|
63
|
+
return ensureTrailingSlash(normalizePath(path));
|
|
64
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Root } from 'hast';
|
|
2
2
|
import { CONTINUE, SKIP, visit } from 'unist-util-visit';
|
|
3
3
|
import type { Transformer } from 'unified';
|
|
4
|
-
import type { MarkdownProcessorPluginOptions } from './markdown-
|
|
4
|
+
import type { MarkdownProcessorPluginOptions } from './markdown-processor';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* rehype plugin that adds `dir` attributes to `<code>` and `<pre>`
|
|
@@ -4,7 +4,7 @@ import { h } from 'hastscript';
|
|
|
4
4
|
import type { Transformer } from 'unified';
|
|
5
5
|
import { SKIP, visit } from 'unist-util-visit';
|
|
6
6
|
import { anchorLinkIconPath } from './anchor-icon';
|
|
7
|
-
import type { MarkdownProcessorPluginOptions } from './markdown-
|
|
7
|
+
import type { MarkdownProcessorPluginOptions } from './markdown-processor';
|
|
8
8
|
|
|
9
9
|
const AnchorLinkIcon = h(
|
|
10
10
|
'span',
|
|
@@ -12,7 +12,7 @@ import { toMarkdown } from 'mdast-util-to-markdown';
|
|
|
12
12
|
import { toString } from 'mdast-util-to-string';
|
|
13
13
|
import type { Plugin, Transformer } from 'unified';
|
|
14
14
|
import { visit } from 'unist-util-visit';
|
|
15
|
-
import type { MarkdownProcessorPluginOptions } from './markdown-
|
|
15
|
+
import type { MarkdownProcessorPluginOptions } from './markdown-processor';
|
|
16
16
|
import type { StarlightIcon } from '../types';
|
|
17
17
|
import { Icons } from '../components-internals/Icons';
|
|
18
18
|
import { fromHtml } from 'hast-util-from-html';
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
import { rehypeHeadingIds } from '@astrojs/markdown-remark';
|
|
1
|
+
import { isUnifiedProcessor, rehypeHeadingIds } from '@astrojs/markdown-remark';
|
|
2
2
|
import type { Root as RehypeRoot } from 'hast';
|
|
3
3
|
import type { Root as RemarkRoot } from 'mdast';
|
|
4
4
|
import remarkDirective from 'remark-directive';
|
|
5
5
|
import type { Plugin } from 'unified';
|
|
6
6
|
import type { VFile } from 'vfile';
|
|
7
|
-
import { remarkAsides } from './asides';
|
|
8
|
-
import { rehypeRtlCodeSupport } from './code-rtl-support';
|
|
9
|
-
import rehypeAutolinkHeadings from './heading-links';
|
|
7
|
+
import { remarkAsides, remarkDirectivesRestoration } from './remark-asides';
|
|
8
|
+
import { rehypeRtlCodeSupport } from './rehype-code-rtl-support';
|
|
9
|
+
import rehypeAutolinkHeadings from './rehype-heading-links';
|
|
10
10
|
import {
|
|
11
11
|
getMarkdownProcessorPaths,
|
|
12
12
|
shouldTransformPath,
|
|
13
13
|
type MarkdownProcessorPluginOptions,
|
|
14
|
-
} from './markdown-
|
|
14
|
+
} from './markdown-processor';
|
|
15
|
+
|
|
16
|
+
// Re-exported so callers can narrow `markdown.processor` to the Unified processor and use the
|
|
17
|
+
// remark directive-restoration plugin through the same lazy import that loads the optional
|
|
18
|
+
// `@astrojs/markdown-remark` peer dependency.
|
|
19
|
+
export { isUnifiedProcessor, remarkDirectivesRestoration };
|
|
15
20
|
|
|
16
21
|
/** List of remark plugins to apply. */
|
|
17
22
|
export function starlightRemarkPlugins(options: MarkdownProcessorPluginOptions): RemarkPlugin[] {
|
package/integrations/satteri.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fileURLToPath } from 'node:url';
|
|
2
|
-
import {
|
|
2
|
+
import { satteriHeadingIdsPlugin } from '@astrojs/markdown-satteri';
|
|
3
3
|
import type { Element, Properties } from 'hast';
|
|
4
4
|
import type { Paragraph } from 'mdast';
|
|
5
5
|
import { directiveToMarkdown } from 'mdast-util-directive';
|
|
@@ -16,15 +16,11 @@ import {
|
|
|
16
16
|
getMarkdownProcessorPaths,
|
|
17
17
|
shouldTransformPath,
|
|
18
18
|
type MarkdownProcessorPluginOptions,
|
|
19
|
-
} from './markdown-
|
|
19
|
+
} from './markdown-processor';
|
|
20
20
|
import { Icons } from '../components-internals/Icons';
|
|
21
21
|
import { throwInvalidAsideIconError } from './asides-error';
|
|
22
22
|
import type { StarlightIcon } from '../types';
|
|
23
23
|
|
|
24
|
-
// Re-exported so callers can narrow `markdown.processor` to a Sätteri processor through the same
|
|
25
|
-
// lazy import that loads the optional `@astrojs/markdown-satteri` peer dependency.
|
|
26
|
-
export { isSatteriProcessor };
|
|
27
|
-
|
|
28
24
|
export function starlightSatteriPlugins(options: MarkdownProcessorPluginOptions): {
|
|
29
25
|
mdastPlugins: MdastPluginInput[];
|
|
30
26
|
hastPlugins: HastPluginInput[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import type { ViteUserConfig } from 'astro';
|
|
3
|
+
|
|
4
|
+
// https://vite.dev/guide/api-plugin#hook-filters
|
|
5
|
+
const componentsBarrelIdFilter = /[\\/]components\.ts(?:\?.*)?$/;
|
|
6
|
+
|
|
7
|
+
const backSlashRegex = /\\/g;
|
|
8
|
+
const queryStringRegex = /\?.*$/;
|
|
9
|
+
|
|
10
|
+
const starlightComponentsBarrelId = normalizeId(
|
|
11
|
+
fileURLToPath(new URL('../components.ts', import.meta.url))
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Vite plugin that marks the Starlight components barrel file as having no side effects so that
|
|
16
|
+
* lazy barrel optimization can be applied to it.
|
|
17
|
+
*
|
|
18
|
+
* @see https://rolldown.rs/in-depth/lazy-barrel-optimization
|
|
19
|
+
*/
|
|
20
|
+
export function vitePluginStarlightLazyBarrelOptimization(): VitePlugin {
|
|
21
|
+
return {
|
|
22
|
+
name: 'vite-plugin-starlight-lazy-barrel-optimization',
|
|
23
|
+
enforce: 'pre',
|
|
24
|
+
transform: {
|
|
25
|
+
filter: {
|
|
26
|
+
id: componentsBarrelIdFilter,
|
|
27
|
+
},
|
|
28
|
+
handler(code, id) {
|
|
29
|
+
if (normalizeId(id) !== starlightComponentsBarrelId) return;
|
|
30
|
+
return { code, moduleSideEffects: false };
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function normalizeId(id: string) {
|
|
37
|
+
return id.replace(backSlashRegex, '/').replace(queryStringRegex, '');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type VitePlugin = NonNullable<ViteUserConfig['plugins']>[number];
|
|
@@ -17,7 +17,7 @@ function resolveVirtualModuleId<T extends string>(id: T): `\0${T}` {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/** Vite plugin that exposes Starlight user config and project context via virtual modules. */
|
|
20
|
-
export function
|
|
20
|
+
export function vitePluginStarlightVirtualModules(
|
|
21
21
|
{
|
|
22
22
|
command,
|
|
23
23
|
isNodeCompatibleEnv,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/starlight",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.0",
|
|
4
4
|
"description": "Build beautiful, high-performance documentation websites with Astro",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -42,27 +42,26 @@
|
|
|
42
42
|
"./style/markdown.css": "./style/markdown.css"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@astrojs/markdown-
|
|
46
|
-
"astro": "^
|
|
45
|
+
"@astrojs/markdown-remark": "^7.2.0",
|
|
46
|
+
"astro": "^7.0.2"
|
|
47
47
|
},
|
|
48
48
|
"peerDependenciesMeta": {
|
|
49
|
-
"@astrojs/markdown-
|
|
49
|
+
"@astrojs/markdown-remark": {
|
|
50
50
|
"optional": true
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@astrojs/markdown-
|
|
54
|
+
"@astrojs/markdown-remark": "^7.2.0",
|
|
55
55
|
"@playwright/test": "^1.59.1",
|
|
56
56
|
"@types/node": "^22.19.17",
|
|
57
57
|
"@vitest/coverage-v8": "^4.1.5",
|
|
58
|
-
"astro": "^
|
|
58
|
+
"astro": "^7.0.2",
|
|
59
59
|
"linkedom": "^0.18.12",
|
|
60
|
-
"satteri": "^0.8.1",
|
|
61
60
|
"vitest": "^4.1.5"
|
|
62
61
|
},
|
|
63
62
|
"dependencies": {
|
|
64
|
-
"@astrojs/markdown-
|
|
65
|
-
"@astrojs/mdx": "^
|
|
63
|
+
"@astrojs/markdown-satteri": "^0.3.2",
|
|
64
|
+
"@astrojs/mdx": "^7.0.0",
|
|
66
65
|
"@astrojs/sitemap": "^3.7.2",
|
|
67
66
|
"@pagefind/default-ui": "^1.3.0",
|
|
68
67
|
"@types/hast": "^3.0.4",
|
|
@@ -85,6 +84,7 @@
|
|
|
85
84
|
"rehype": "^13.0.2",
|
|
86
85
|
"rehype-format": "^5.0.1",
|
|
87
86
|
"remark-directive": "^4.0.0",
|
|
87
|
+
"satteri": "^0.9.1",
|
|
88
88
|
"ultrahtml": "^1.6.0",
|
|
89
89
|
"unified": "^11.0.5",
|
|
90
90
|
"unist-util-visit": "^5.1.0",
|
|
@@ -16,14 +16,9 @@ const {
|
|
|
16
16
|
Astro.props,
|
|
17
17
|
'Invalid prop passed to the `<Badge/>` component.'
|
|
18
18
|
);
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The fragment around the element is used as a workaround to avoid a trailing whitespace in the output.
|
|
22
|
-
* @see https://github.com/withastro/compiler/issues/1003
|
|
23
|
-
*/
|
|
24
19
|
---
|
|
25
20
|
|
|
26
|
-
|
|
21
|
+
<span class:list={['sl-badge', variant, size, customClass]} {...attrs}>{text}</span>
|
|
27
22
|
|
|
28
23
|
<style>
|
|
29
24
|
@layer starlight.components {
|
|
@@ -11,24 +11,17 @@ interface Props {
|
|
|
11
11
|
|
|
12
12
|
const { name, label, size = '1em', color } = Astro.props;
|
|
13
13
|
const a11yAttrs = label ? ({ 'aria-label': label } as const) : ({ 'aria-hidden': 'true' } as const);
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The fragment around the element is used as a workaround to avoid a trailing whitespace in the output.
|
|
17
|
-
* @see https://github.com/withastro/compiler/issues/1003
|
|
18
|
-
*/
|
|
19
14
|
---
|
|
20
15
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/>
|
|
31
|
-
</>
|
|
16
|
+
<svg
|
|
17
|
+
{...a11yAttrs}
|
|
18
|
+
class={Astro.props.class}
|
|
19
|
+
width="16"
|
|
20
|
+
height="16"
|
|
21
|
+
viewBox="0 0 24 24"
|
|
22
|
+
fill="currentColor"
|
|
23
|
+
set:html={Icons[name]}
|
|
24
|
+
/>
|
|
32
25
|
|
|
33
26
|
<style define:vars={{ 'sl-icon-color': color, 'sl-icon-size': size }}>
|
|
34
27
|
@layer starlight.components {
|