@astrojs/starlight 0.25.2 → 0.25.4
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/__e2e__/collection-config.test.ts +3 -1
- package/components/Head.astro +0 -2
- package/components/TableOfContents/starlight-toc.ts +10 -5
- package/integrations/virtual-user-config.ts +10 -3
- package/package.json +6 -6
- package/user-components/file-tree-icons.ts +17 -0
- package/utils/head.ts +3 -1
- package/utils/i18n.ts +3 -3
- /package/__e2e__/fixtures/{custom-src-dir → custom src-dir}/astro.config.mjs +0 -0
- /package/__e2e__/fixtures/{custom-src-dir → custom src-dir}/node_modules/.bin/astro +0 -0
- /package/__e2e__/fixtures/{custom-src-dir → custom src-dir}/package.json +0 -0
- /package/__e2e__/fixtures/{custom-src-dir → custom src-dir}/www/content/config.ts +0 -0
- /package/__e2e__/fixtures/{custom-src-dir → custom src-dir}/www/env.d.ts +0 -0
- /package/__e2e__/fixtures/{custom-src-dir → custom src-dir}/www/pages/custom.astro +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @astrojs/starlight
|
|
2
2
|
|
|
3
|
+
## 0.25.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2155](https://github.com/withastro/starlight/pull/2155) [`8bed886`](https://github.com/withastro/starlight/commit/8bed88674c732040cf66d392372386a8917a2eeb) Thanks [@delucis](https://github.com/delucis)! - Improves page load performance on slower devices
|
|
8
|
+
|
|
9
|
+
- [#2167](https://github.com/withastro/starlight/pull/2167) [`9ac7725`](https://github.com/withastro/starlight/commit/9ac7725dbe84f3fab9b191452471d8eaffd55048) Thanks [@delucis](https://github.com/delucis)! - Fixes an issue detecting the built-in locale when running Starlight in a web container environment on Firefox
|
|
10
|
+
|
|
11
|
+
- [#2166](https://github.com/withastro/starlight/pull/2166) [`4f12049`](https://github.com/withastro/starlight/commit/4f120490e914fb308e909b97890a11bb95ae964c) Thanks [@delucis](https://github.com/delucis)! - Updates `@astrojs/mdx`, `@astrojs/sitemap`, `astro-expressive-code`, `unified`, and `vfile` dependencies to the latest version
|
|
12
|
+
|
|
13
|
+
## 0.25.3
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#2154](https://github.com/withastro/starlight/pull/2154) [`0b381d5`](https://github.com/withastro/starlight/commit/0b381d53f23c31492cf415057d960f9a5eaa2f3d) Thanks [@mktbsh](https://github.com/mktbsh)! - Updates `<head>` logic to deduplicate `<link rel="canonical">` tags. This means that custom canonicals set via frontmatter now override the default canonical generated by Starlight.
|
|
18
|
+
|
|
19
|
+
- [#2157](https://github.com/withastro/starlight/pull/2157) [`6757d97`](https://github.com/withastro/starlight/commit/6757d97b0ae789e0c61a776ad9af742858c663b0) Thanks [@astrobot-houston](https://github.com/astrobot-houston)! - Updates file tree icon mapping to correctly map `.cjs` and `.mjs` extensions in several contexts
|
|
20
|
+
|
|
21
|
+
- [#2156](https://github.com/withastro/starlight/pull/2156) [`904ad47`](https://github.com/withastro/starlight/commit/904ad47ea9588c0b1d8c583f3f04e4ae199474d9) Thanks [@delucis](https://github.com/delucis)! - Fixes builds for projects with a space in their pathname
|
|
22
|
+
|
|
23
|
+
- [#2137](https://github.com/withastro/starlight/pull/2137) [`703903b`](https://github.com/withastro/starlight/commit/703903bb782c3fabd3fe914e40494c00f12ec945) Thanks [@cevdetardaharan](https://github.com/cevdetardaharan)! - Removes `twitter:title` and `twitter:description` meta tags from `<head>`
|
|
24
|
+
|
|
3
25
|
## 0.25.2
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { expect, testFactory } from './test-utils';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// This fixture contains a space in the directory so that we have a smoke test for building
|
|
4
|
+
// Starlight projects with pathnames like this, which are a common source of bugs.
|
|
5
|
+
const test = await testFactory('./fixtures/custom src-dir/');
|
|
4
6
|
|
|
5
7
|
test('builds a custom page using the `<StarlightPage>` component and a custom `srcDir`', async ({
|
|
6
8
|
page,
|
package/components/Head.astro
CHANGED
|
@@ -48,8 +48,6 @@ const headDefaults: z.input<ReturnType<typeof HeadConfigSchema>> = [
|
|
|
48
48
|
tag: 'meta',
|
|
49
49
|
attrs: { name: 'twitter:card', content: 'summary_large_image' },
|
|
50
50
|
},
|
|
51
|
-
{ tag: 'meta', attrs: { name: 'twitter:title', content: data.title } },
|
|
52
|
-
{ tag: 'meta', attrs: { name: 'twitter:description', content: description } },
|
|
53
51
|
];
|
|
54
52
|
|
|
55
53
|
if (description)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PAGE_TITLE_ID } from '../../constants';
|
|
2
2
|
|
|
3
3
|
export class StarlightTOC extends HTMLElement {
|
|
4
|
-
private _current = this.querySelector('a[aria-current="true"]')
|
|
4
|
+
private _current = this.querySelector<HTMLAnchorElement>('a[aria-current="true"]');
|
|
5
5
|
private minH = parseInt(this.dataset.minH || '2', 10);
|
|
6
6
|
private maxH = parseInt(this.dataset.maxH || '3', 10);
|
|
7
7
|
|
|
@@ -12,9 +12,15 @@ export class StarlightTOC extends HTMLElement {
|
|
|
12
12
|
this._current = link;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
private onIdle = (cb: IdleRequestCallback) =>
|
|
16
|
+
(window.requestIdleCallback || ((cb) => setTimeout(cb, 1)))(cb);
|
|
17
|
+
|
|
15
18
|
constructor() {
|
|
16
19
|
super();
|
|
20
|
+
this.onIdle(() => this.init());
|
|
21
|
+
}
|
|
17
22
|
|
|
23
|
+
private init = (): void => {
|
|
18
24
|
/** All the links in the table of contents. */
|
|
19
25
|
const links = [...this.querySelectorAll('a')];
|
|
20
26
|
|
|
@@ -73,21 +79,20 @@ export class StarlightTOC extends HTMLElement {
|
|
|
73
79
|
|
|
74
80
|
let observer: IntersectionObserver | undefined;
|
|
75
81
|
const observe = () => {
|
|
76
|
-
if (observer)
|
|
82
|
+
if (observer) return;
|
|
77
83
|
observer = new IntersectionObserver(setCurrent, { rootMargin: this.getRootMargin() });
|
|
78
84
|
toObserve.forEach((h) => observer!.observe(h));
|
|
79
85
|
};
|
|
80
86
|
observe();
|
|
81
87
|
|
|
82
|
-
const onIdle = window.requestIdleCallback || ((cb) => setTimeout(cb, 1));
|
|
83
88
|
let timeout: NodeJS.Timeout;
|
|
84
89
|
window.addEventListener('resize', () => {
|
|
85
90
|
// Disable intersection observer while window is resizing.
|
|
86
91
|
if (observer) observer.disconnect();
|
|
87
92
|
clearTimeout(timeout);
|
|
88
|
-
timeout = setTimeout(() => onIdle(observe), 200);
|
|
93
|
+
timeout = setTimeout(() => this.onIdle(observe), 200);
|
|
89
94
|
});
|
|
90
|
-
}
|
|
95
|
+
};
|
|
91
96
|
|
|
92
97
|
private getRootMargin(): `-${number}px 0% ${number}px` {
|
|
93
98
|
const navBarHeight = document.querySelector('header')?.getBoundingClientRect().height || 0;
|
|
@@ -19,8 +19,15 @@ export function vitePluginStarlightUserConfig(
|
|
|
19
19
|
build: Pick<AstroConfig['build'], 'format'>;
|
|
20
20
|
}
|
|
21
21
|
): NonNullable<ViteUserConfig['plugins']>[number] {
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Resolves module IDs to a usable format:
|
|
24
|
+
* - Relative paths (e.g. `'./module.js'`) are resolved against `base` and formatted as an absolute path.
|
|
25
|
+
* - Package identifiers (e.g. `'module'`) are returned unchanged.
|
|
26
|
+
*
|
|
27
|
+
* By default, `base` is the project root directory.
|
|
28
|
+
*/
|
|
29
|
+
const resolveId = (id: string, base = root) =>
|
|
30
|
+
JSON.stringify(id.startsWith('.') ? resolve(fileURLToPath(base), id) : id);
|
|
24
31
|
|
|
25
32
|
const virtualComponentModules = Object.fromEntries(
|
|
26
33
|
Object.entries(opts.components).map(([name, path]) => [
|
|
@@ -50,7 +57,7 @@ export function vitePluginStarlightUserConfig(
|
|
|
50
57
|
: 'export const logos = {};',
|
|
51
58
|
'virtual:starlight/collection-config': `let userCollections;
|
|
52
59
|
try {
|
|
53
|
-
userCollections = (await import(
|
|
60
|
+
userCollections = (await import(${resolveId('./content/config.ts', srcDir)})).collections;
|
|
54
61
|
} catch {}
|
|
55
62
|
export const collections = userCollections;`,
|
|
56
63
|
...virtualComponentModules,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/starlight",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.4",
|
|
4
4
|
"description": "Build beautiful, high-performance documentation websites with Astro",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -182,12 +182,12 @@
|
|
|
182
182
|
"vitest": "^1.6.0"
|
|
183
183
|
},
|
|
184
184
|
"dependencies": {
|
|
185
|
-
"@astrojs/mdx": "^3.1.
|
|
186
|
-
"@astrojs/sitemap": "^3.1.
|
|
185
|
+
"@astrojs/mdx": "^3.1.3",
|
|
186
|
+
"@astrojs/sitemap": "^3.1.6",
|
|
187
187
|
"@pagefind/default-ui": "^1.0.3",
|
|
188
188
|
"@types/hast": "^3.0.4",
|
|
189
189
|
"@types/mdast": "^4.0.4",
|
|
190
|
-
"astro-expressive-code": "^0.35.
|
|
190
|
+
"astro-expressive-code": "^0.35.6",
|
|
191
191
|
"bcp-47": "^2.1.0",
|
|
192
192
|
"hast-util-from-html": "^2.0.1",
|
|
193
193
|
"hast-util-select": "^6.0.2",
|
|
@@ -200,9 +200,9 @@
|
|
|
200
200
|
"rehype": "^13.0.1",
|
|
201
201
|
"rehype-format": "^5.0.0",
|
|
202
202
|
"remark-directive": "^3.0.0",
|
|
203
|
-
"unified": "^11.0.
|
|
203
|
+
"unified": "^11.0.5",
|
|
204
204
|
"unist-util-visit": "^5.0.0",
|
|
205
|
-
"vfile": "^6.0.
|
|
205
|
+
"vfile": "^6.0.2"
|
|
206
206
|
},
|
|
207
207
|
"scripts": {
|
|
208
208
|
"test": "vitest",
|
|
@@ -44,6 +44,8 @@ export const definitions: Definitions = {
|
|
|
44
44
|
COMMIT_EDITMSG: 'seti:git',
|
|
45
45
|
MERGE_MSG: 'seti:git',
|
|
46
46
|
'karma.conf.js': 'seti:karma',
|
|
47
|
+
'karma.conf.cjs': 'seti:karma',
|
|
48
|
+
'karma.conf.mjs': 'seti:karma',
|
|
47
49
|
'karma.conf.coffee': 'seti:karma',
|
|
48
50
|
'README.md': 'seti:info',
|
|
49
51
|
'README.txt': 'seti:info',
|
|
@@ -74,6 +76,7 @@ export const definitions: Definitions = {
|
|
|
74
76
|
'WORKSPACE.bazel': 'seti:bazel',
|
|
75
77
|
'bower.json': 'seti:bower',
|
|
76
78
|
'Bower.json': 'seti:bower',
|
|
79
|
+
'eslint.config.js': 'seti:eslint',
|
|
77
80
|
'firebase.json': 'seti:firebase',
|
|
78
81
|
geckodriver: 'seti:firefox',
|
|
79
82
|
'Gruntfile.js': 'seti:grunt',
|
|
@@ -91,22 +94,28 @@ export const definitions: Definitions = {
|
|
|
91
94
|
'sass-lint.yml': 'seti:sass',
|
|
92
95
|
'stylelint.config.js': 'seti:stylelint',
|
|
93
96
|
'stylelint.config.cjs': 'seti:stylelint',
|
|
97
|
+
'stylelint.config.mjs': 'seti:stylelint',
|
|
94
98
|
'yarn.clean': 'seti:yarn',
|
|
95
99
|
'yarn.lock': 'seti:yarn',
|
|
96
100
|
'webpack.config.js': 'seti:webpack',
|
|
97
101
|
'webpack.config.cjs': 'seti:webpack',
|
|
102
|
+
'webpack.config.mjs': 'seti:webpack',
|
|
98
103
|
'webpack.config.ts': 'seti:webpack',
|
|
99
104
|
'webpack.config.build.js': 'seti:webpack',
|
|
100
105
|
'webpack.config.build.cjs': 'seti:webpack',
|
|
106
|
+
'webpack.config.build.mjs': 'seti:webpack',
|
|
101
107
|
'webpack.config.build.ts': 'seti:webpack',
|
|
102
108
|
'webpack.common.js': 'seti:webpack',
|
|
103
109
|
'webpack.common.cjs': 'seti:webpack',
|
|
110
|
+
'webpack.common.mjs': 'seti:webpack',
|
|
104
111
|
'webpack.common.ts': 'seti:webpack',
|
|
105
112
|
'webpack.dev.js': 'seti:webpack',
|
|
106
113
|
'webpack.dev.cjs': 'seti:webpack',
|
|
114
|
+
'webpack.dev.mjs': 'seti:webpack',
|
|
107
115
|
'webpack.dev.ts': 'seti:webpack',
|
|
108
116
|
'webpack.prod.js': 'seti:webpack',
|
|
109
117
|
'webpack.prod.cjs': 'seti:webpack',
|
|
118
|
+
'webpack.prod.mjs': 'seti:webpack',
|
|
110
119
|
'webpack.prod.ts': 'seti:webpack',
|
|
111
120
|
'npm-debug.log': 'seti:npm_ignored',
|
|
112
121
|
},
|
|
@@ -218,8 +227,16 @@ export const definitions: Definitions = {
|
|
|
218
227
|
'.properties': 'seti:java',
|
|
219
228
|
'.js': 'seti:javascript',
|
|
220
229
|
'.js.map': 'seti:javascript',
|
|
230
|
+
'.cjs': 'seti:javascript',
|
|
231
|
+
'.cjs.map': 'seti:javascript',
|
|
232
|
+
'.mjs': 'seti:javascript',
|
|
233
|
+
'.mjs.map': 'seti:javascript',
|
|
221
234
|
'.spec.js': 'seti:javascript',
|
|
235
|
+
'.spec.cjs': 'seti:javascript',
|
|
236
|
+
'.spec.mjs': 'seti:javascript',
|
|
222
237
|
'.test.js': 'seti:javascript',
|
|
238
|
+
'.test.cjs': 'seti:javascript',
|
|
239
|
+
'.test.mjs': 'seti:javascript',
|
|
223
240
|
'.es': 'seti:javascript',
|
|
224
241
|
'.es5': 'seti:javascript',
|
|
225
242
|
'.es6': 'seti:javascript',
|
package/utils/head.ts
CHANGED
|
@@ -12,7 +12,7 @@ export function createHead(defaults: HeadUserConfig, ...heads: HeadConfig[]) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* Test if a head config object contains a matching `<title>` or `<meta>` tag.
|
|
15
|
+
* Test if a head config object contains a matching `<title>` or `<meta>` or `<link rel="canonical">` tag.
|
|
16
16
|
*
|
|
17
17
|
* For example, will return true if `head` already contains
|
|
18
18
|
* `<meta name="description" content="A">` and the passed `tag`
|
|
@@ -25,6 +25,8 @@ function hasTag(head: HeadConfig, entry: HeadConfig[number]): boolean {
|
|
|
25
25
|
return head.some(({ tag }) => tag === 'title');
|
|
26
26
|
case 'meta':
|
|
27
27
|
return hasOneOf(head, entry, ['name', 'property', 'http-equiv']);
|
|
28
|
+
case 'link':
|
|
29
|
+
return head.some(({ attrs }) => attrs.rel === 'canonical');
|
|
28
30
|
default:
|
|
29
31
|
return false;
|
|
30
32
|
}
|
package/utils/i18n.ts
CHANGED
|
@@ -2,9 +2,6 @@ import type { AstroConfig } from 'astro';
|
|
|
2
2
|
import { AstroError } from 'astro/errors';
|
|
3
3
|
import type { StarlightConfig } from './user-config';
|
|
4
4
|
|
|
5
|
-
/** Informations about the built-in default locale used as a fallback when no locales are defined. */
|
|
6
|
-
export const BuiltInDefaultLocale = { ...getLocaleInfo('en'), lang: 'en' };
|
|
7
|
-
|
|
8
5
|
/**
|
|
9
6
|
* A list of well-known right-to-left languages used as a fallback when determining the text
|
|
10
7
|
* direction of a locale is not supported by the `Intl.Locale` API in the current environment.
|
|
@@ -14,6 +11,9 @@ export const BuiltInDefaultLocale = { ...getLocaleInfo('en'), lang: 'en' };
|
|
|
14
11
|
*/
|
|
15
12
|
const wellKnownRTL = ['ar', 'fa', 'he', 'prs', 'ps', 'syc', 'ug', 'ur'];
|
|
16
13
|
|
|
14
|
+
/** Informations about the built-in default locale used as a fallback when no locales are defined. */
|
|
15
|
+
export const BuiltInDefaultLocale = { ...getLocaleInfo('en'), lang: 'en' };
|
|
16
|
+
|
|
17
17
|
/**
|
|
18
18
|
* Processes the Astro and Starlight i18n configurations to generate/update them accordingly:
|
|
19
19
|
*
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|