@astrojs/starlight 0.30.5 → 0.31.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 CHANGED
@@ -1,5 +1,49 @@
1
1
  # @astrojs/starlight
2
2
 
3
+ ## 0.31.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#2777](https://github.com/withastro/starlight/pull/2777) [`88f4214`](https://github.com/withastro/starlight/commit/88f42145888f3a04f20898fcb700c1e65be48bb2) Thanks [@hippotastic](https://github.com/hippotastic)! - Updates `astro-expressive-code` dependency to the latest version (0.40).
8
+
9
+ This includes an update to the latest Shiki version (1.26.1), providing access to all current Shiki themes and syntax highlighting languages, and adding the config options `shiki.engine`, `shiki.bundledLangs`, `shiki.langAlias` and `removeUnusedThemes`. It also adds new style variants to the optional collapsible sections plugin.
10
+
11
+ See the [Expressive Code release notes](https://expressive-code.com/releases/#0400) for full details.
12
+
13
+ - [#2736](https://github.com/withastro/starlight/pull/2736) [`29a885b`](https://github.com/withastro/starlight/commit/29a885be43f29150d6abd905f3ef7e1dccb99c98) Thanks [@delucis](https://github.com/delucis)! - ⚠️ **BREAKING CHANGE:** The minimum supported version of Astro is now 5.1.5
14
+
15
+ Please update Astro and Starlight together:
16
+
17
+ ```sh
18
+ npx @astrojs/upgrade
19
+ ```
20
+
21
+ - [#2728](https://github.com/withastro/starlight/pull/2728) [`e187383`](https://github.com/withastro/starlight/commit/e1873834d4a4328084a9ac056a089ee5b8f13103) Thanks [@delucis](https://github.com/delucis)! - Updates minimum Pagefind dependency to v1.3.0, sets new defaults for Pagefind’s ranking options, and adds support for manually configuring the ranking options
22
+
23
+ The new ranking option defaults have been evaluated against Starlight’s own docs to improve the quality of search results. See [“Customize Pagefind's result ranking”](https://pagefind.app/docs/ranking/) for more details about how they work.
24
+
25
+ - [#157](https://github.com/withastro/starlight/pull/157) [`23bf960`](https://github.com/withastro/starlight/commit/23bf960aed36445600b6ccecb2138a5b461e2929) Thanks [@tony-sull](https://github.com/tony-sull)! - Adds a print stylesheet to improve the appearance of Starlight docs pages when printed
26
+
27
+ - [#2728](https://github.com/withastro/starlight/pull/2728) [`e187383`](https://github.com/withastro/starlight/commit/e1873834d4a4328084a9ac056a089ee5b8f13103) Thanks [@delucis](https://github.com/delucis)! - Fixes Pagefind logging to respect the Astro log level. When using Astro’s `--verbose` or `--silent` CLI flags, these are now respected by Pagefind as well.
28
+
29
+ ### Patch Changes
30
+
31
+ - [#2792](https://github.com/withastro/starlight/pull/2792) [`412effb`](https://github.com/withastro/starlight/commit/412effb5a63c6026ea4faa0d09bcbd4a3c9fad4d) Thanks [@dhruvkb](https://github.com/dhruvkb)! - Uses semantic `var(--sl-color-hairline)` for the page sidebar border instead of `var(--sl-color-gray-6)`. This is visually the same as previously but makes it easier to override the hairline color consistently across a site.
32
+
33
+ - [#2736](https://github.com/withastro/starlight/pull/2736) [`29a885b`](https://github.com/withastro/starlight/commit/29a885be43f29150d6abd905f3ef7e1dccb99c98) Thanks [@delucis](https://github.com/delucis)! - Updates internal dependencies `@astrojs/sitemap` and `@astrojs/mdx` to the latest versions
34
+
35
+ - [#2782](https://github.com/withastro/starlight/pull/2782) [`d9d415b`](https://github.com/withastro/starlight/commit/d9d415b4558c7995319299e9c9e1520c87c3078e) Thanks [@delucis](https://github.com/delucis)! - Fixes a documentation link in the JSDoc comment for the `StarlightExpressiveCodeOptions` type
36
+
37
+ - [#2708](https://github.com/withastro/starlight/pull/2708) [`442c819`](https://github.com/withastro/starlight/commit/442c8194dbcbe58e155d4c1f8d897a04605666e5) Thanks [@delucis](https://github.com/delucis)! - Fixes colour contrast correction in code blocks
38
+
39
+ ## 0.30.6
40
+
41
+ ### Patch Changes
42
+
43
+ - [#2722](https://github.com/withastro/starlight/pull/2722) [`0b206d3`](https://github.com/withastro/starlight/commit/0b206d3a23f0876146dc17f5e507984362917696) Thanks [@techfg](https://github.com/techfg)! - Fixes display of long site title on mobile
44
+
45
+ - [#2762](https://github.com/withastro/starlight/pull/2762) [`7ab1576`](https://github.com/withastro/starlight/commit/7ab157639da62fdc6b444b0280ad4c9d5ee4872f) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Prevents the header title from being translated by automatic translation systems.
46
+
3
47
  ## 0.30.5
4
48
 
5
49
  ### Patch Changes
@@ -7,7 +7,7 @@ const { editUrl } = Astro.props;
7
7
 
8
8
  {
9
9
  editUrl && (
10
- <a href={editUrl} class="sl-flex">
10
+ <a href={editUrl} class="sl-flex print:hidden">
11
11
  <Icon name="pencil" size="1.2em" />
12
12
  {Astro.locals.t('page.editLink')}
13
13
  </a>
@@ -19,10 +19,10 @@ const shouldRenderSearch =
19
19
  <div class="title-wrapper sl-flex">
20
20
  <SiteTitle {...Astro.props} />
21
21
  </div>
22
- <div class="sl-flex">
22
+ <div class="sl-flex print:hidden">
23
23
  {shouldRenderSearch && <Search {...Astro.props} />}
24
24
  </div>
25
- <div class="sl-hidden md:sl-flex right-group">
25
+ <div class="sl-hidden md:sl-flex print:hidden right-group">
26
26
  <div class="sl-flex social-icons">
27
27
  <SocialIcons {...Astro.props} />
28
28
  </div>
@@ -45,6 +45,7 @@ const shouldRenderSearch =
45
45
  /* Avoid clipping focus ring around link inside title wrapper. */
46
46
  padding: 0.25rem;
47
47
  margin: -0.25rem;
48
+ min-width: 0;
48
49
  }
49
50
 
50
51
  .right-group,
@@ -3,7 +3,7 @@ import type { Props } from '../props';
3
3
  import Icon from '../user-components/Icon.astro';
4
4
  ---
5
5
 
6
- <starlight-menu-button>
6
+ <starlight-menu-button class="print:hidden">
7
7
  <button
8
8
  aria-expanded="false"
9
9
  aria-label={Astro.locals.t('menuButton.accessibleLabel')}
@@ -31,6 +31,8 @@ import '../style/asides.css';
31
31
  // Important that this is the last import so it can override built-in styles.
32
32
  import 'virtual:starlight/user-css';
33
33
 
34
+ import printHref from '../style/print.css?url&no-inline';
35
+
34
36
  const pagefindEnabled =
35
37
  Astro.props.entry.slug !== '404' &&
36
38
  !Astro.props.entry.slug.endsWith('/404') &&
@@ -75,6 +77,7 @@ if (pagefindEnabled) mainDataAttributes['data-pagefind-body'] = '';
75
77
  }
76
78
  </style>
77
79
  <ThemeProvider {...Astro.props} />
80
+ <link rel="stylesheet" href={printHref} media="print" />
78
81
  </head>
79
82
  <body>
80
83
  <SkipLink {...Astro.props} />
@@ -9,7 +9,7 @@ const { hasSidebar } = Astro.props;
9
9
  <header class="header"><slot name="header" /></header>
10
10
  {
11
11
  hasSidebar && (
12
- <nav class="sidebar" aria-label={Astro.locals.t('sidebarNav.accessibleLabel')}>
12
+ <nav class="sidebar print:hidden" aria-label={Astro.locals.t('sidebarNav.accessibleLabel')}>
13
13
  <MobileMenuToggle {...Astro.props} />
14
14
  <div id="starlight__sidebar" class="sidebar-pane">
15
15
  <div class="sidebar-content sl-flex">
@@ -7,7 +7,7 @@ const { prev, next } = pagination;
7
7
  const isRtl = dir === 'rtl';
8
8
  ---
9
9
 
10
- <div class="pagination-links" dir={dir}>
10
+ <div class="pagination-links print:hidden" dir={dir}>
11
11
  {
12
12
  prev && (
13
13
  <a href={prev.href} rel="prev">
@@ -76,6 +76,8 @@ if (project.trailingSlash === 'never') dataAttributes['data-strip-trailing-slash
76
76
  </script>
77
77
 
78
78
  <script>
79
+ import { pagefindUserConfig } from 'virtual:starlight/pagefind-config';
80
+
79
81
  class SiteSearch extends HTMLElement {
80
82
  constructor() {
81
83
  super();
@@ -139,6 +141,7 @@ if (project.trailingSlash === 'never') dataAttributes['data-strip-trailing-slash
139
141
  // @ts-expect-error — Missing types for @pagefind/default-ui package.
140
142
  const { PagefindUI } = await import('@pagefind/default-ui');
141
143
  new PagefindUI({
144
+ ...pagefindUserConfig,
142
145
  element: '#starlight__search',
143
146
  baseUrl: import.meta.env.BASE_URL,
144
147
  bundlePath: import.meta.env.BASE_URL.replace(/\/$/, '') + '/pagefind/',
@@ -10,7 +10,7 @@ const { siteTitle, siteTitleHref } = Astro.props;
10
10
  config.logo && logos.dark && (
11
11
  <>
12
12
  <img
13
- class:list={{ 'light:sl-hidden': !('src' in config.logo) }}
13
+ class:list={{ 'light:sl-hidden print:hidden': !('src' in config.logo) }}
14
14
  alt={config.logo.alt}
15
15
  src={logos.dark.src}
16
16
  width={logos.dark.width}
@@ -19,7 +19,7 @@ const { siteTitle, siteTitleHref } = Astro.props;
19
19
  {/* Show light alternate if a user configure both light and dark logos. */}
20
20
  {!('src' in config.logo) && (
21
21
  <img
22
- class="dark:sl-hidden"
22
+ class="dark:sl-hidden print:block"
23
23
  alt={config.logo.alt}
24
24
  src={logos.light?.src}
25
25
  width={logos.light?.width}
@@ -29,7 +29,7 @@ const { siteTitle, siteTitleHref } = Astro.props;
29
29
  </>
30
30
  )
31
31
  }
32
- <span class:list={{ 'sr-only': config.logo?.replacesTitle }}>
32
+ <span class:list={{ 'sr-only': config.logo?.replacesTitle }} translate="no">
33
33
  {siteTitle}
34
34
  </span>
35
35
  </a>
@@ -5,7 +5,7 @@ import type { Props } from '../props';
5
5
  <div class="lg:sl-flex">
6
6
  {
7
7
  Astro.props.toc && (
8
- <aside class="right-sidebar-container">
8
+ <aside class="right-sidebar-container print:hidden">
9
9
  <div class="right-sidebar">
10
10
  <slot name="right-sidebar" />
11
11
  </div>
@@ -32,7 +32,7 @@ import type { Props } from '../props';
32
32
  .right-sidebar {
33
33
  position: fixed;
34
34
  top: 0;
35
- border-inline-start: 1px solid var(--sl-color-gray-6);
35
+ border-inline-start: 1px solid var(--sl-color-hairline);
36
36
  padding-top: var(--sl-nav-height);
37
37
  width: 100%;
38
38
  height: 100vh;
package/index.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  /// <reference path="./virtual.d.ts" />
9
9
 
10
10
  import mdx from '@astrojs/mdx';
11
- import type { AstroIntegration } from 'astro';
11
+ import type { AstroIntegration, AstroIntegrationLogger } from 'astro';
12
12
  import { AstroError } from 'astro/errors';
13
13
  import { spawn } from 'node:child_process';
14
14
  import { dirname, relative } from 'node:path';
@@ -145,13 +145,14 @@ export default function StarlightIntegration(
145
145
  injectPluginTranslationsTypes(pluginTranslations, injectTypes);
146
146
  },
147
147
 
148
- 'astro:build:done': ({ dir }) => {
148
+ 'astro:build:done': ({ dir, logger }) => {
149
149
  if (!userConfig.pagefind) return;
150
+ const loglevelFlag = getPagefindLoggingFlags(logger.options.level);
150
151
  const targetDir = fileURLToPath(dir);
151
152
  const cwd = dirname(fileURLToPath(import.meta.url));
152
153
  const relativeDir = relative(cwd, targetDir);
153
154
  return new Promise<void>((resolve) => {
154
- spawn('npx', ['-y', 'pagefind', '--site', relativeDir], {
155
+ spawn('npx', ['-y', 'pagefind', ...loglevelFlag, '--site', relativeDir], {
155
156
  stdio: 'inherit',
156
157
  shell: true,
157
158
  cwd,
@@ -161,3 +162,19 @@ export default function StarlightIntegration(
161
162
  },
162
163
  };
163
164
  }
165
+
166
+ /** Map the logging level of Astro’s logger to one of Pagefind’s logging level flags. */
167
+ function getPagefindLoggingFlags(level: AstroIntegrationLogger['options']['level']) {
168
+ switch (level) {
169
+ case 'silent':
170
+ case 'error':
171
+ return ['--silent'];
172
+ case 'warn':
173
+ return ['--quiet'];
174
+ case 'debug':
175
+ return ['--verbose'];
176
+ case 'info':
177
+ default:
178
+ return [];
179
+ }
180
+ }
@@ -20,7 +20,7 @@ export type StarlightExpressiveCodeOptions = Omit<AstroExpressiveCodeOptions, 't
20
20
  /**
21
21
  * Set the themes used to style code blocks.
22
22
  *
23
- * See the [Expressive Code `themes` documentation](https://github.com/expressive-code/expressive-code/blob/main/packages/astro-expressive-code/README.md#themes)
23
+ * See the [Expressive Code `themes` documentation](https://expressive-code.com/guides/themes/)
24
24
  * for details of the supported theme formats.
25
25
  *
26
26
  * Starlight uses the dark and light variants of Sarah Drasner’s
@@ -79,6 +79,7 @@ export function applyStarlightUiThemeColors(theme: ExpressiveCodeTheme) {
79
79
 
80
80
  // Set theme `bg` color property for contrast calculations
81
81
  theme.bg = isDark ? '#23262f' : '#f6f7f9';
82
+ theme.colors['editor.background'] = theme.bg;
82
83
  // Set actual background color to the appropriate Starlight CSS variable
83
84
  const editorBackgroundColor = isDark ? 'var(--sl-color-gray-6)' : 'var(--sl-color-gray-7)';
84
85
 
@@ -100,6 +100,7 @@ export function vitePluginStarlightUserConfig(
100
100
  } catch {}
101
101
  export const collections = userCollections;`,
102
102
  'virtual:starlight/plugin-translations': `export default ${JSON.stringify(pluginTranslations)}`,
103
+ 'virtual:starlight/pagefind-config': `export const pagefindUserConfig = ${JSON.stringify(opts.pagefind || {})}`,
103
104
  ...virtualComponentModules,
104
105
  } satisfies Record<string, string>;
105
106
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/starlight",
3
- "version": "0.30.5",
3
+ "version": "0.31.0",
4
4
  "description": "Build beautiful, high-performance documentation websites with Astro",
5
5
  "keywords": [
6
6
  "docs",
@@ -172,25 +172,25 @@
172
172
  "./style/markdown.css": "./style/markdown.css"
173
173
  },
174
174
  "peerDependencies": {
175
- "astro": "^5.0.0"
175
+ "astro": "^5.1.5"
176
176
  },
177
177
  "devDependencies": {
178
- "@astrojs/markdown-remark": "^6.0.0",
178
+ "@astrojs/markdown-remark": "^6.0.1",
179
179
  "@playwright/test": "^1.45.0",
180
180
  "@types/node": "^18.16.19",
181
181
  "@vitest/coverage-v8": "2.1.6",
182
- "astro": "^5.0.2",
182
+ "astro": "^5.1.5",
183
183
  "linkedom": "^0.18.4",
184
184
  "vitest": "2.1.6"
185
185
  },
186
186
  "dependencies": {
187
- "@astrojs/mdx": "^4.0.1",
188
- "@astrojs/sitemap": "^3.1.6",
189
- "@pagefind/default-ui": "^1.0.3",
187
+ "@astrojs/mdx": "^4.0.5",
188
+ "@astrojs/sitemap": "^3.2.1",
189
+ "@pagefind/default-ui": "^1.3.0",
190
190
  "@types/hast": "^3.0.4",
191
191
  "@types/js-yaml": "^4.0.9",
192
192
  "@types/mdast": "^4.0.4",
193
- "astro-expressive-code": "^0.38.3",
193
+ "astro-expressive-code": "^0.40.0",
194
194
  "bcp-47": "^2.1.0",
195
195
  "hast-util-from-html": "^2.0.1",
196
196
  "hast-util-select": "^6.0.2",
@@ -201,7 +201,7 @@
201
201
  "mdast-util-directive": "^3.0.0",
202
202
  "mdast-util-to-markdown": "^2.1.0",
203
203
  "mdast-util-to-string": "^4.0.0",
204
- "pagefind": "^1.0.3",
204
+ "pagefind": "^1.3.0",
205
205
  "rehype": "^13.0.1",
206
206
  "rehype-format": "^5.0.0",
207
207
  "remark-directive": "^3.0.0",
@@ -0,0 +1,44 @@
1
+ import { z } from 'astro/zod';
2
+
3
+ const pagefindSchema = z.object({
4
+ /** Configure how search result rankings are calculated by Pagefind. */
5
+ ranking: z
6
+ .object({
7
+ /**
8
+ * Set Pagefind’s `pageLength` ranking option.
9
+ *
10
+ * The default value is `0.1` and values must be in the range `0` to `1`.
11
+ *
12
+ * @see https://pagefind.app/docs/ranking/#configuring-page-length
13
+ */
14
+ pageLength: z.number().min(0).max(1).default(0.1),
15
+ /**
16
+ * Set Pagefind’s `termFrequency` ranking option.
17
+ *
18
+ * The default value is `0.1` and values must be in the range `0` to `1`.
19
+ *
20
+ * @see https://pagefind.app/docs/ranking/#configuring-term-frequency
21
+ */
22
+ termFrequency: z.number().min(0).max(1).default(0.1),
23
+ /**
24
+ * Set Pagefind’s `termSaturation` ranking option.
25
+ *
26
+ * The default value is `2` and values must be in the range `0` to `2`.
27
+ *
28
+ * @see https://pagefind.app/docs/ranking/#configuring-term-saturation
29
+ */
30
+ termSaturation: z.number().min(0).max(2).default(2),
31
+ /**
32
+ * Set Pagefind’s `termSimilarity` ranking option.
33
+ *
34
+ * The default value is `9` and values must be greater than or equal to `0`.
35
+ *
36
+ * @see https://pagefind.app/docs/ranking/#configuring-term-similarity
37
+ */
38
+ termSimilarity: z.number().min(0).default(9),
39
+ })
40
+ .default({}),
41
+ });
42
+
43
+ export const PagefindConfigSchema = () => pagefindSchema;
44
+ export const PagefindConfigDefaults = () => pagefindSchema.parse({});
@@ -0,0 +1,180 @@
1
+ @media print {
2
+ /**
3
+ This is increased in specificity so it works even when injected into pages before regular styles.
4
+ TODO: Just use `:root` once we move to @layer.
5
+ Same goes for the use of `!important` in this file.
6
+ */
7
+ :root[data-theme]:is(:root) {
8
+ /* Colours — force light mode when printing */
9
+ --sl-color-white: hsl(224, 10%, 10%);
10
+ --sl-color-gray-1: hsl(224, 14%, 16%);
11
+ --sl-color-gray-2: hsl(224, 10%, 23%);
12
+ --sl-color-gray-3: hsl(224, 7%, 36%);
13
+ --sl-color-gray-4: hsl(224, 6%, 56%);
14
+ --sl-color-gray-5: hsl(224, 6%, 77%);
15
+ --sl-color-gray-6: hsl(224, 20%, 94%);
16
+ --sl-color-gray-7: hsl(224, 19%, 97%);
17
+ --sl-color-black: hsl(0, 0%, 100%);
18
+
19
+ --sl-color-orange-high: hsl(var(--sl-hue-orange), 80%, 25%);
20
+ --sl-color-orange: hsl(var(--sl-hue-orange), 90%, 60%);
21
+ --sl-color-orange-low: hsl(var(--sl-hue-orange), 90%, 88%);
22
+ --sl-color-green-high: hsl(var(--sl-hue-green), 80%, 22%);
23
+ --sl-color-green: hsl(var(--sl-hue-green), 90%, 46%);
24
+ --sl-color-green-low: hsl(var(--sl-hue-green), 85%, 90%);
25
+ --sl-color-blue-high: hsl(var(--sl-hue-blue), 80%, 30%);
26
+ --sl-color-blue: hsl(var(--sl-hue-blue), 90%, 60%);
27
+ --sl-color-blue-low: hsl(var(--sl-hue-blue), 88%, 90%);
28
+ --sl-color-purple-high: hsl(var(--sl-hue-purple), 90%, 30%);
29
+ --sl-color-purple: hsl(var(--sl-hue-purple), 90%, 60%);
30
+ --sl-color-purple-low: hsl(var(--sl-hue-purple), 80%, 90%);
31
+ --sl-color-red-high: hsl(var(--sl-hue-red), 80%, 30%);
32
+ --sl-color-red: hsl(var(--sl-hue-red), 90%, 60%);
33
+ --sl-color-red-low: hsl(var(--sl-hue-red), 80%, 90%);
34
+
35
+ --sl-color-accent-high: hsl(234, 80%, 30%);
36
+ --sl-color-accent: hsl(234, 90%, 60%);
37
+ --sl-color-accent-low: hsl(234, 88%, 90%);
38
+
39
+ --sl-color-text-accent: var(--sl-color-accent);
40
+ --sl-color-text-invert: var(--sl-color-black);
41
+ --sl-color-bg-nav: var(--sl-color-gray-7);
42
+ --sl-color-bg-sidebar: var(--sl-color-bg);
43
+ --sl-color-bg-inline-code: var(--sl-color-gray-6);
44
+ --sl-color-bg-accent: var(--sl-color-accent);
45
+ --sl-color-hairline-light: var(--sl-color-gray-6);
46
+ --sl-color-hairline-shade: var(--sl-color-gray-6);
47
+
48
+ --sl-color-backdrop-overlay: hsla(225, 9%, 36%, 0.66);
49
+
50
+ /* Disable shadows when printing. */
51
+ --sl-shadow-sm: none;
52
+ --sl-shadow-md: none;
53
+ --sl-shadow-lg: none;
54
+ }
55
+
56
+ /* Utility classes for controlling element visibility when printing. */
57
+ .print\:hidden {
58
+ display: none !important;
59
+ }
60
+ .print\:flex {
61
+ display: flex !important;
62
+ }
63
+ .print\:block {
64
+ display: block !important;
65
+ }
66
+
67
+ /* Page layout tweaks. */
68
+ main {
69
+ padding-bottom: 0 !important;
70
+ }
71
+ main > .content-panel {
72
+ padding-block-start: 0 !important;
73
+ }
74
+ .content-panel + .content-panel {
75
+ border: 0 !important;
76
+ }
77
+ /* components/PageFrame.astro */
78
+ .page > header {
79
+ position: relative !important;
80
+ }
81
+ .page > .main-frame {
82
+ padding-top: 0;
83
+ padding-inline-start: 0;
84
+ }
85
+ /* components/TwoColumnContent.astro */
86
+ .main-pane {
87
+ --sl-sidebar-width: 0px !important;
88
+ --sl-content-width: 100% !important;
89
+ }
90
+ /* components/Banner.astro */
91
+ .sl-banner {
92
+ --sl-color-banner-text: var(--sl-color-white) !important;
93
+ background-color: transparent !important;
94
+ }
95
+
96
+ /* components/MarkdownContent.astro */
97
+ .sl-markdown-content :is(h1, h2, h3, h4, h5, h6) {
98
+ break-after: avoid;
99
+ }
100
+ .sl-markdown-content :is(p, li) {
101
+ orphans: 2;
102
+ widows: 2;
103
+ }
104
+ .sl-markdown-content pre {
105
+ overflow-x: hidden !important;
106
+ white-space: pre-wrap !important;
107
+ }
108
+ .sl-markdown-content .expressive-code,
109
+ .sl-markdown-content figure,
110
+ .sl-markdown-content pre {
111
+ break-inside: avoid;
112
+ }
113
+ .expressive-code .frame.is-terminal .header::before {
114
+ /* Ensure terminal frame dots are visible even if backgrounds are disabled. */
115
+ box-shadow: inset 99rem 99rem var(--sl-color-gray-5);
116
+ }
117
+ .expressive-code .frame.has-title:not(.is-terminal) .header {
118
+ /* Divide title bar and code without relying on background colors. */
119
+ background: transparent !important;
120
+ border-bottom: 1px solid var(--sl-color-gray-6) !important;
121
+ }
122
+ .expressive-code .frame.has-title:not(.is-terminal) .title {
123
+ /* Hide title tab background color. */
124
+ background: transparent !important;
125
+ }
126
+ .expressive-code .frame.has-title:not(.is-terminal) .title::after {
127
+ /* Remove title tab highlight. */
128
+ border-top: 0 !important;
129
+ }
130
+ .expressive-code .copy {
131
+ /* Ensure Expressive Code copy button is hidden when printing from touch devices. */
132
+ display: none !important;
133
+ }
134
+ /* Inline code */
135
+ .sl-markdown-content code:not(:where(.not-content *)) {
136
+ background-color: transparent !important;
137
+ padding: 0 !important;
138
+ margin-block: unset !important;
139
+ font-size: 0.9375em !important;
140
+ }
141
+
142
+ /* user-components/Badge.astro */
143
+ .sl-badge {
144
+ background: transparent !important;
145
+ color: var(--sl-color-white) !important;
146
+ }
147
+
148
+ /* user-components/FileTree.astro */
149
+ starlight-file-tree {
150
+ break-inside: avoid;
151
+ }
152
+ starlight-file-tree .highlight {
153
+ outline: 3px solid var(--sl-color-accent-low);
154
+ color: var(--sl-color-text) !important;
155
+ background-color: transparent !important;
156
+ }
157
+
158
+ /* user-components/Aside.astro */
159
+ .starlight-aside {
160
+ break-inside: avoid;
161
+ }
162
+
163
+ /* user-components/LinkButton.astro */
164
+ .sl-link-button.primary {
165
+ background: transparent !important;
166
+ border-color: var(--sl-color-white) !important;
167
+ color: var(--sl-color-white) !important;
168
+ }
169
+
170
+ /* user-components/Tabs.astro */
171
+ starlight-tabs {
172
+ break-inside: avoid;
173
+ }
174
+
175
+ /* user-components/Steps.astro */
176
+ .sl-steps > li::after {
177
+ /* Ensure steps guidelines are visible when background colors are disabled. */
178
+ box-shadow: inset 99rem 99rem var(--sl-color-hairline-light);
179
+ }
180
+ }
@@ -47,7 +47,7 @@ const html = processFileTree(fileTreeHtml, Astro.locals.t('fileTree.directory'))
47
47
  starlight-file-tree :global(.directory > details > summary:hover .tree-icon) {
48
48
  cursor: pointer;
49
49
  color: var(--sl-color-text-accent);
50
- fill: var(--sl-color-text-accent);
50
+ fill: currentColor;
51
51
  }
52
52
 
53
53
  starlight-file-tree :global(.directory > details > summary:hover ~ ul) {
@@ -55,7 +55,7 @@ const html = processFileTree(fileTreeHtml, Astro.locals.t('fileTree.directory'))
55
55
  }
56
56
 
57
57
  starlight-file-tree :global(.directory > details > summary:hover .highlight .tree-icon) {
58
- fill: var(--sl-color-text-invert);
58
+ fill: currentColor;
59
59
  }
60
60
 
61
61
  starlight-file-tree :global(ul) {
@@ -129,6 +129,6 @@ const html = processFileTree(fileTreeHtml, Astro.locals.t('fileTree.directory'))
129
129
  }
130
130
 
131
131
  starlight-file-tree :global(.highlight svg.tree-icon) {
132
- fill: var(--sl-color-text-invert);
132
+ fill: currentColor;
133
133
  }
134
134
  </style>
@@ -5,10 +5,11 @@ import { ExpressiveCodeSchema } from '../schemas/expressiveCode';
5
5
  import { FaviconSchema } from '../schemas/favicon';
6
6
  import { HeadConfigSchema } from '../schemas/head';
7
7
  import { LogoConfigSchema } from '../schemas/logo';
8
+ import { PagefindConfigDefaults, PagefindConfigSchema } from '../schemas/pagefind';
8
9
  import { SidebarItemSchema } from '../schemas/sidebar';
10
+ import { TitleConfigSchema, TitleTransformConfigSchema } from '../schemas/site-title';
9
11
  import { SocialLinksSchema } from '../schemas/social';
10
12
  import { TableOfContentsSchema } from '../schemas/tableOfContents';
11
- import { TitleConfigSchema, TitleTransformConfigSchema } from '../schemas/site-title';
12
13
  import { BuiltInDefaultLocale } from './i18n';
13
14
 
14
15
  const LocaleSchema = z.object({
@@ -191,11 +192,15 @@ const UserConfigSchema = z.object({
191
192
  expressiveCode: ExpressiveCodeSchema(),
192
193
 
193
194
  /**
194
- * Define whether Starlight’s default site search provider Pagefind is enabled.
195
- * Set to `false` to disable indexing your site with Pagefind.
196
- * This will also hide the default search UI if in use.
195
+ * Configure Starlight’s default site search provider Pagefind. Set to `false` to disable indexing
196
+ * your site with Pagefind, which will also hide the default search UI if in use.
197
197
  */
198
- pagefind: z.boolean().optional(),
198
+ pagefind: z
199
+ .boolean()
200
+ // Transform `true` to our default config object.
201
+ .transform((val) => val && PagefindConfigDefaults())
202
+ .or(PagefindConfigSchema())
203
+ .optional(),
199
204
 
200
205
  /** Specify paths to components that should override Starlight’s default components */
201
206
  components: ComponentConfigSchema(),
@@ -227,10 +232,13 @@ export const StarlightConfigSchema = UserConfigSchema.strict()
227
232
  .transform((config) => ({
228
233
  ...config,
229
234
  // Pagefind only defaults to true if prerender is also true.
230
- pagefind: config.pagefind ?? config.prerender,
235
+ pagefind:
236
+ typeof config.pagefind === 'undefined'
237
+ ? config.prerender && PagefindConfigDefaults()
238
+ : config.pagefind,
231
239
  }))
232
240
  .refine((config) => !(!config.prerender && config.pagefind), {
233
- message: 'Pagefind search is not support with prerendering disabled.',
241
+ message: 'Pagefind search is not supported with prerendering disabled.',
234
242
  })
235
243
  .transform(({ title, locales, defaultLocale, ...config }, ctx) => {
236
244
  const configuredLocales = Object.keys(locales ?? {});
@@ -16,6 +16,12 @@ declare module 'virtual:starlight/collection-config' {
16
16
  export const collections: import('astro:content').ContentConfig['collections'] | undefined;
17
17
  }
18
18
 
19
+ declare module 'virtual:starlight/pagefind-config' {
20
+ export const pagefindUserConfig: Partial<
21
+ Extract<import('./types').StarlightConfig['pagefind'], object>
22
+ >;
23
+ }
24
+
19
25
  declare module 'virtual:starlight/components/Banner' {
20
26
  const Banner: typeof import('./components/Banner.astro').default;
21
27
  export default Banner;