@astrojs/starlight 0.14.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,67 @@
1
1
  # @astrojs/starlight
2
2
 
3
+ ## 0.15.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1273](https://github.com/withastro/starlight/pull/1273) [`ae53155`](https://github.com/withastro/starlight/commit/ae531557aa4d42bd27c15f8f08bb3ca8242c9beb) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Updates `<SocialIcon />` styling for improved accessibility. Specifically, the component now meets the [Target Size (Minimum)](https://www.w3.org/WAI/WCAG22/Understanding/target-size-minimum.html) success criteria defined by [Web Content Accessibility Guidelines (WCAG) 2.2](https://www.w3.org/TR/WCAG22/).
8
+
9
+ - [#1289](https://github.com/withastro/starlight/pull/1289) [`9bd343f`](https://github.com/withastro/starlight/commit/9bd343fb1efab90a0aa03a95b1928a53c1674000) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Adds French translations for Expressive Code UI
10
+
11
+ - [#1280](https://github.com/withastro/starlight/pull/1280) [`6b1693d`](https://github.com/withastro/starlight/commit/6b1693d55552a48316a31d986e1cbaf695f10a61) Thanks [@kevinzunigacuellar](https://github.com/kevinzunigacuellar)! - Adds Spanish translations for Expressive Code UI
12
+
13
+ - [#1276](https://github.com/withastro/starlight/pull/1276) [`667f23d`](https://github.com/withastro/starlight/commit/667f23d615742b44bb18ace39d981f8797b8ac55) Thanks [@hippotastic](https://github.com/hippotastic)! - Updates `astro-expressive-code` dependency to the latest version
14
+
15
+ - [#1266](https://github.com/withastro/starlight/pull/1266) [`c9edf30`](https://github.com/withastro/starlight/commit/c9edf30b16f66757797dcaa5161b4afc18027476) Thanks [@alex-way](https://github.com/alex-way)! - Removes redundant subprocess calls in git last-updated time utility to improve performance
16
+
17
+ - [#1278](https://github.com/withastro/starlight/pull/1278) [`e88abb0`](https://github.com/withastro/starlight/commit/e88abb0cc8b329500c15bc77aaed3907ec7dc507) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Exports the `StarlightUserConfig` TypeScript type representing the user's Starlight configuration received by plugins.
18
+
19
+ ## 0.15.0
20
+
21
+ ### Minor Changes
22
+
23
+ - [#1238](https://github.com/withastro/starlight/pull/1238) [`02a808e`](https://github.com/withastro/starlight/commit/02a808e4a0b9ac2383576e3495f6a766b663d773) Thanks [@delucis](https://github.com/delucis)! - Add support for Astro v4, drop support for Astro v3
24
+
25
+ ⚠️ **BREAKING CHANGE** Astro v3 is no longer supported. Make sure you [update Astro](https://docs.astro.build/en/guides/upgrade-to/v4/) and any other integrations at the same time as updating Starlight.
26
+
27
+ Use the new `@astrojs/upgrade` command to upgrade Astro and Starlight together:
28
+
29
+ ```sh
30
+ npx @astrojs/upgrade
31
+ ```
32
+
33
+ - [#1242](https://github.com/withastro/starlight/pull/1242) [`d8fc9e1`](https://github.com/withastro/starlight/commit/d8fc9e15bd2ae4c945b5a3856a6ce3b5629e8b29) Thanks [@delucis](https://github.com/delucis)! - Enables link prefetching on hover by default
34
+
35
+ Astro v4’s [prefetch](https://docs.astro.build/en/guides/prefetch) support is now enabled by default. If `prefetch` is not set in `astro.config.mjs`, Starlight will use `prefetch: { prefetchAll: true, defaultStrategy: 'hover' }` by default.
36
+
37
+ If you want to preserve previous behaviour, disable link prefetching in `astro.config.mjs`:
38
+
39
+ ```js
40
+ import { defineConfig } from 'astro/config';
41
+ import starlight from '@astrojs/starlight';
42
+
43
+ export default defineConfig({
44
+ // Disable link prefetching:
45
+ prefetch: false,
46
+
47
+ integrations: [
48
+ starlight({
49
+ // ...
50
+ }),
51
+ ],
52
+ });
53
+ ```
54
+
55
+ ### Patch Changes
56
+
57
+ - [#1226](https://github.com/withastro/starlight/pull/1226) [`909afa2`](https://github.com/withastro/starlight/commit/909afa2d468099e237bfbd25eda56270b7b00082) Thanks [@tlandmangh](https://github.com/tlandmangh)! - Add Dutch translations of default aside labels
58
+
59
+ - [#1243](https://github.com/withastro/starlight/pull/1243) [`ee234eb`](https://github.com/withastro/starlight/commit/ee234ebddcba8d07e2c879f33e38631c8955ffcf) Thanks [@khajimatov](https://github.com/khajimatov)! - Fix typo in Russian untranslated content notice
60
+
61
+ - [#1170](https://github.com/withastro/starlight/pull/1170) [`bcc2301`](https://github.com/withastro/starlight/commit/bcc2301c06796edec3923c666078e82eaf5a1990) Thanks [@tmcw](https://github.com/tmcw)! - Fix timezone-reliance in LastUpdated
62
+
63
+ - [#1203](https://github.com/withastro/starlight/pull/1203) [`4601449`](https://github.com/withastro/starlight/commit/4601449894bbbd619e4149788113090b67697fe1) Thanks [@orhun](https://github.com/orhun)! - Adds Matrix social link icon
64
+
3
65
  ## 0.14.0
4
66
 
5
67
  ### Minor Changes
@@ -101,4 +101,6 @@ export const Icons = {
101
101
  '<path d="M22.04 7.6c0-2.8-2.19-5.1-4.75-5.93a15.19 15.19 0 0 0-10.44.55C3.16 3.96 2 7.78 1.95 11.58c-.02 3.12.3 11.36 4.94 11.42 3.45.04 3.97-4.4 5.56-6.55 1.14-1.52 2.6-1.95 4.4-2.4 3.1-.76 5.2-3.2 5.2-6.44Z"/>',
102
102
  slack:
103
103
  '<path d="M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52Zm1.271 0a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313ZM8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834Zm0 1.271a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312Zm10.122 2.521a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834Zm-1.268 0a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312Zm-2.523 10.122a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52Zm0-1.268a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313Z"/>',
104
+ matrix:
105
+ '<path d="M22.5 1.5v21h-2.25V24H24V0h-3.75v1.5h2.25ZM7.46 7.95V9.1h.04a3.02 3.02 0 0 1 2.61-1.39c.54 0 1.03.1 1.48.32.44.2.78.58 1.01 1.1.26-.37.6-.7 1.03-.99.44-.28.95-.43 1.55-.43.45 0 .87.06 1.26.17.38.11.71.29.99.53.27.24.49.56.64.95.15.4.23.86.23 1.42v5.72h-2.34v-4.85c0-.29-.01-.56-.04-.8a1.73 1.73 0 0 0-.18-.67 1.1 1.1 0 0 0-.44-.45 1.6 1.6 0 0 0-.78-.16c-.33 0-.6.06-.8.19-.2.12-.37.29-.48.5a2 2 0 0 0-.23.69c-.04.26-.06.52-.06.78v4.77H10.6v-4.8l-.01-.75a2.29 2.29 0 0 0-.14-.69c-.08-.2-.23-.38-.42-.5a1.5 1.5 0 0 0-.85-.2c-.15.01-.3.04-.44.08-.19.06-.37.15-.52.28-.18.14-.32.34-.44.6-.12.26-.18.6-.18 1.02v4.96H5.25V7.94h2.21ZM1.5 1.5v21h2.25V24H0V0h3.75v1.5H1.5Z"/>',
104
106
  };
@@ -9,7 +9,7 @@ const { labels, lang, lastUpdated } = Astro.props;
9
9
  <p>
10
10
  {labels['page.lastUpdated']}{' '}
11
11
  <time datetime={lastUpdated.toISOString()}>
12
- {lastUpdated.toLocaleDateString(lang, { dateStyle: 'medium' })}
12
+ {lastUpdated.toLocaleDateString(lang, { dateStyle: 'medium', timeZone: 'UTC' })}
13
13
  </time>
14
14
  </p>
15
15
  )
@@ -24,6 +24,8 @@ const links = Object.entries(config.social || {}) as [Platform, SocialConfig][];
24
24
  <style>
25
25
  a {
26
26
  color: var(--sl-color-text-accent);
27
+ padding: 0.5em;
28
+ margin: -0.5em;
27
29
  }
28
30
  a:hover {
29
31
  opacity: 0.66;
package/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import mdx from '@astrojs/mdx';
2
- import type { AstroIntegration, AstroUserConfig } from 'astro';
2
+ import type { AstroIntegration } from 'astro';
3
3
  import { spawn } from 'node:child_process';
4
4
  import { dirname, relative } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
@@ -41,11 +41,11 @@ export default function StarlightIntegration({
41
41
 
42
42
  injectRoute({
43
43
  pattern: '404',
44
- entryPoint: '@astrojs/starlight/404.astro',
44
+ entrypoint: '@astrojs/starlight/404.astro',
45
45
  });
46
46
  injectRoute({
47
47
  pattern: '[...slug]',
48
- entryPoint: '@astrojs/starlight/index.astro',
48
+ entrypoint: '@astrojs/starlight/index.astro',
49
49
  });
50
50
  // Add built-in integrations only if they are not already added by the user through the
51
51
  // config or by a plugin.
@@ -61,7 +61,7 @@ export default function StarlightIntegration({
61
61
  if (!allIntegrations.find(({ name }) => name === '@astrojs/mdx')) {
62
62
  integrations.push(mdx());
63
63
  }
64
- const newConfig: AstroUserConfig = {
64
+ updateConfig({
65
65
  integrations,
66
66
  vite: {
67
67
  plugins: [vitePluginStarlightUserConfig(starlightConfig, config)],
@@ -76,8 +76,9 @@ export default function StarlightIntegration({
76
76
  config.markdown.shikiConfig.theme !== 'github-dark' ? {} : { theme: 'css-variables' },
77
77
  },
78
78
  scopedStyleStrategy: 'where',
79
- };
80
- updateConfig(newConfig);
79
+ // If not already configured, default to prefetching all links on hover.
80
+ prefetch: config.prefetch ?? { prefetchAll: true },
81
+ });
81
82
  },
82
83
 
83
84
  'astro:build:done': ({ dir }) => {
@@ -1,3 +1,5 @@
1
+ /// <reference types="mdast-util-directive" />
2
+
1
3
  import type { AstroConfig, AstroUserConfig } from 'astro';
2
4
  import { h as _h, s as _s, type Properties } from 'hastscript';
3
5
  import type { Paragraph as P, Root } from 'mdast';
@@ -100,7 +102,7 @@ function remarkAsides(options: AsidesOptions): Plugin<[], Root> {
100
102
  const locale = pathToLocale(file.history[0], options);
101
103
  const t = options.useTranslations(locale);
102
104
  visit(tree, (node, index, parent) => {
103
- if (!parent || index === null || node.type !== 'containerDirective') {
105
+ if (!parent || index === undefined || node.type !== 'containerDirective') {
104
106
  return;
105
107
  }
106
108
  const variant = node.name;
@@ -112,7 +114,7 @@ function remarkAsides(options: AsidesOptions): Plugin<[], Root> {
112
114
  // title prop, and remove the paragraph from children.
113
115
  let title = t(`aside.${variant}`);
114
116
  remove(node, (child): boolean | void => {
115
- if (child.data?.directiveLabel) {
117
+ if (child.data && 'directiveLabel' in child.data && child.data.directiveLabel) {
116
118
  if (
117
119
  'children' in child &&
118
120
  Array.isArray(child.children) &&
@@ -1,4 +1,4 @@
1
- import type { Root } from 'hastscript/lib/core';
1
+ import type { Root } from 'hast';
2
2
  import { CONTINUE, SKIP, visit } from 'unist-util-visit';
3
3
 
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/starlight",
3
- "version": "0.14.0",
3
+ "version": "0.15.1",
4
4
  "description": "Build beautiful, high-performance documentation websites with Astro",
5
5
  "keywords": [
6
6
  "docs",
@@ -159,32 +159,34 @@
159
159
  "./style/markdown.css": "./style/markdown.css"
160
160
  },
161
161
  "peerDependencies": {
162
- "astro": "^3.2.0"
162
+ "astro": "^4.0.0"
163
163
  },
164
164
  "devDependencies": {
165
- "@astrojs/markdown-remark": "^3.2.1",
165
+ "@astrojs/markdown-remark": "^4.0.0",
166
166
  "@types/node": "^18.16.19",
167
167
  "@vitest/coverage-v8": "^0.33.0",
168
- "astro": "^3.2.3",
168
+ "astro": "^4.0.1",
169
169
  "vitest": "^0.33.0"
170
170
  },
171
171
  "dependencies": {
172
- "@astrojs/mdx": "^1.1.0",
172
+ "@astrojs/mdx": "^2.0.0",
173
173
  "@astrojs/sitemap": "^3.0.3",
174
174
  "@pagefind/default-ui": "^1.0.3",
175
- "@types/mdast": "^3.0.11",
176
- "astro-expressive-code": "^0.29.0",
175
+ "@types/hast": "^3.0.3",
176
+ "@types/mdast": "^4.0.3",
177
+ "astro-expressive-code": "^0.30.1",
177
178
  "bcp-47": "^2.1.0",
178
179
  "execa": "^8.0.1",
179
- "hast-util-select": "^5.0.5",
180
- "hastscript": "^7.2.0",
180
+ "hast-util-select": "^6.0.2",
181
+ "hastscript": "^8.0.0",
182
+ "mdast-util-directive": "^3.0.0",
181
183
  "pagefind": "^1.0.3",
182
- "rehype": "^12.0.1",
183
- "remark-directive": "^2.0.1",
184
- "unified": "^10.1.2",
185
- "unist-util-remove": "^3.1.1",
186
- "unist-util-visit": "^4.1.2",
187
- "vfile": "^5.3.7"
184
+ "rehype": "^13.0.1",
185
+ "remark-directive": "^3.0.0",
186
+ "unified": "^11.0.4",
187
+ "unist-util-remove": "^4.0.0",
188
+ "unist-util-visit": "^5.0.0",
189
+ "vfile": "^6.0.1"
188
190
  },
189
191
  "scripts": {
190
192
  "test": "vitest",
package/schemas/social.ts CHANGED
@@ -25,6 +25,7 @@ export const socialLinks = [
25
25
  'reddit',
26
26
  'patreon',
27
27
  'slack',
28
+ 'matrix',
28
29
  ] as const;
29
30
 
30
31
  export const SocialLinksSchema = () =>
@@ -65,6 +66,7 @@ export const SocialLinksSchema = () =>
65
66
  reddit: 'Reddit',
66
67
  patreon: 'Patreon',
67
68
  slack: 'Slack',
69
+ matrix: 'Matrix',
68
70
  }[key];
69
71
  labelledLinks[key] = { label, url };
70
72
  }
@@ -22,5 +22,8 @@
22
22
  "aside.note": "Nota",
23
23
  "aside.tip": "Consejo",
24
24
  "aside.caution": "Precaución",
25
- "aside.danger": "Peligro"
25
+ "aside.danger": "Peligro",
26
+ "expressiveCode.copyButtonCopied": "¡Copiado!",
27
+ "expressiveCode.copyButtonTooltip": "Copiar al portapapeles",
28
+ "expressiveCode.terminalWindowFallbackTitle": "Ventana de terminal"
26
29
  }
@@ -22,5 +22,8 @@
22
22
  "aside.note": "Note",
23
23
  "aside.tip": "Astuce",
24
24
  "aside.caution": "Attention",
25
- "aside.danger": "Danger"
25
+ "aside.danger": "Danger",
26
+ "expressiveCode.copyButtonCopied": "Copié !",
27
+ "expressiveCode.copyButtonTooltip": "Copier dans le presse-papiers",
28
+ "expressiveCode.terminalWindowFallbackTitle": "Fenêtre de terminal"
26
29
  }
@@ -19,8 +19,8 @@
19
19
  "page.previousLink": "Vorige",
20
20
  "page.nextLink": "Volgende",
21
21
  "404.text": "Pagina niet gevonden. Controleer de URL of probeer de zoekbalk.",
22
- "aside.note": "Note",
22
+ "aside.note": "Opmerking",
23
23
  "aside.tip": "Tip",
24
- "aside.caution": "Caution",
25
- "aside.danger": "Danger"
24
+ "aside.caution": "Opgepast",
25
+ "aside.danger": "Gevaar"
26
26
  }
@@ -13,7 +13,7 @@
13
13
  "sidebarNav.accessibleLabel": "Основное",
14
14
  "tableOfContents.onThisPage": "На этой странице",
15
15
  "tableOfContents.overview": "Обзор",
16
- "i18n.untranslatedContent": "Этот содержимое пока не доступно на вашем языке.",
16
+ "i18n.untranslatedContent": "Это содержимое пока не доступно на вашем языке.",
17
17
  "page.editLink": "Редактировать страницу",
18
18
  "page.lastUpdated": "Последнее обновление:",
19
19
  "page.previousLink": "Предыдущая",
package/types.ts CHANGED
@@ -1,2 +1,5 @@
1
1
  export type { StarlightConfig } from './utils/user-config';
2
- export type { StarlightPlugin } from './utils/plugins';
2
+ export type {
3
+ StarlightPlugin,
4
+ StarlightUserConfigWithPlugins as StarlightUserConfig,
5
+ } from './utils/plugins';
@@ -1,3 +1,4 @@
1
+ import type { Element } from 'hast';
1
2
  import { select } from 'hast-util-select';
2
3
  import { rehype } from 'rehype';
3
4
  import { CONTINUE, SKIP, visit } from 'unist-util-visit';
@@ -50,7 +51,7 @@ const getIDs = () => {
50
51
  const tabsProcessor = rehype()
51
52
  .data('settings', { fragment: true })
52
53
  .use(function tabs() {
53
- return (tree, file) => {
54
+ return (tree: Element, file) => {
54
55
  file.data.panels = [];
55
56
  let isFirst = true;
56
57
  visit(tree, 'element', (node) => {
package/utils/git.ts CHANGED
@@ -8,12 +8,9 @@
8
8
  * LICENSE file in the root directory of this source tree.
9
9
  */
10
10
 
11
- import path from 'node:path';
11
+ import { basename, dirname } from 'node:path';
12
12
  import { execaSync } from 'execa';
13
13
 
14
- /** Custom error thrown when git is not found in `PATH`. */
15
- class GitNotFoundError extends Error {}
16
-
17
14
  /** Custom error thrown when the current file is not tracked by git. */
18
15
  class FileNotTrackedError extends Error {}
19
16
 
@@ -22,7 +19,6 @@ class FileNotTrackedError extends Error {}
22
19
  * It gets the commit date instead of author date so that amended commits
23
20
  * can have their dates updated.
24
21
  *
25
- * @throws {GitNotFoundError} If git is not found in `PATH`.
26
22
  * @throws {FileNotTrackedError} If the current file is not tracked by git.
27
23
  * @throws Also throws when `git log` exited with non-zero, or when it outputs
28
24
  * unexpected text.
@@ -34,24 +30,6 @@ export function getFileCommitDate(
34
30
  date: Date;
35
31
  timestamp: number;
36
32
  } {
37
- try {
38
- const { stdout } = execaSync('which', ['git']);
39
- if (!stdout) {
40
- throw new GitNotFoundError(
41
- `Failed to retrieve git history for "${file}" because git is not installed.`
42
- );
43
- }
44
- } catch {}
45
-
46
- try {
47
- const { stdout } = execaSync('test', ['-f', file]);
48
- if (!stdout) {
49
- throw new Error(
50
- `Failed to retrieve git history for "${file}" because the file does not exist.`
51
- );
52
- }
53
- } catch {}
54
-
55
33
  const result = execaSync(
56
34
  'git',
57
35
  [
@@ -60,10 +38,10 @@ export function getFileCommitDate(
60
38
  '--max-count=1',
61
39
  ...(age === 'oldest' ? ['--follow', '--diff-filter=A'] : []),
62
40
  '--',
63
- path.basename(file),
41
+ basename(file),
64
42
  ],
65
43
  {
66
- cwd: path.dirname(file),
44
+ cwd: dirname(file),
67
45
  }
68
46
  );
69
47
  if (result.exitCode !== 0) {
@@ -71,7 +49,6 @@ export function getFileCommitDate(
71
49
  `Failed to retrieve the git history for file "${file}" with exit code ${result.exitCode}: ${result.stderr}`
72
50
  );
73
51
  }
74
- let regex = /^(?<timestamp>\d+)$/;
75
52
 
76
53
  const output = result.stdout.trim();
77
54
 
@@ -81,6 +58,7 @@ export function getFileCommitDate(
81
58
  );
82
59
  }
83
60
 
61
+ const regex = /^(?<timestamp>\d+)$/;
84
62
  const match = output.match(regex);
85
63
 
86
64
  if (!match) {