@astrojs/starlight 0.17.0 → 0.17.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,17 @@
1
1
  # @astrojs/starlight
2
2
 
3
+ ## 0.17.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1437](https://github.com/withastro/starlight/pull/1437) [`655aed4`](https://github.com/withastro/starlight/commit/655aed4840cae59e9abd64b4b585e60f1cfab209) Thanks [@hippotastic](https://github.com/hippotastic)! - Adds Starlight-specific types to `defineEcConfig` function and exports `StarlightExpressiveCodeOptions`.
8
+
9
+ This provides Starlight types and IntelliSense support for your Expressive Code configuration options inside an `ec.config.mjs` file. See the [Expressive Code documentation](https://expressive-code.com/key-features/code-component/#using-an-ecconfigmjs-file) for more information.
10
+
11
+ - [#1420](https://github.com/withastro/starlight/pull/1420) [`275f87f`](https://github.com/withastro/starlight/commit/275f87fd7fc676b9ab323354078c06894e0832c7) Thanks [@abdelhalimjean](https://github.com/abdelhalimjean)! - Fix rare `font-family` issue if users have a font installed with a name of `""`
12
+
13
+ - [#1365](https://github.com/withastro/starlight/pull/1365) [`a0af7cc`](https://github.com/withastro/starlight/commit/a0af7cc696da987a76edab96cdd2329779e87724) Thanks [@kevinzunigacuellar](https://github.com/kevinzunigacuellar)! - Correctly format Pagefind search result links when `trailingSlash: 'never'` is used
14
+
3
15
  ## 0.17.0
4
16
 
5
17
  ### Minor Changes
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  import '@pagefind/default-ui/css/ui.css';
3
3
  import Icon from '../user-components/Icon.astro';
4
+ import project from 'virtual:starlight/project-context';
4
5
  import type { Props } from '../props';
5
6
 
6
7
  const { labels } = Astro.props;
@@ -15,7 +16,10 @@ const pagefindTranslations = {
15
16
  };
16
17
  ---
17
18
 
18
- <site-search data-translations={JSON.stringify(pagefindTranslations)}>
19
+ <site-search
20
+ data-translations={JSON.stringify(pagefindTranslations)}
21
+ data-strip-trailing-slash={project.trailingSlash === 'never'}
22
+ >
19
23
  <button data-open-modal disabled>
20
24
  {
21
25
  /* The span is `aria-hidden` because it is not shown on small screens. Instead, the icon label is used for accessibility purposes. */
@@ -112,10 +116,15 @@ const pagefindTranslations = {
112
116
  translations = JSON.parse(this.dataset.translations || '{}');
113
117
  } catch {}
114
118
 
119
+ const shouldStrip = this.dataset.stripTrailingSlash !== undefined;
120
+ const stripTrailingSlash = (path: string) => path.replace(/(.)\/(#.*)?$/, '$1$2');
121
+ const formatURL = shouldStrip ? stripTrailingSlash : (path: string) => path;
122
+
115
123
  window.addEventListener('DOMContentLoaded', () => {
116
124
  if (import.meta.env.DEV) return;
117
125
  const onIdle = window.requestIdleCallback || ((cb) => setTimeout(cb, 1));
118
126
  onIdle(async () => {
127
+ // @ts-expect-error — Missing types for @pagefind/default-ui package.
119
128
  const { PagefindUI } = await import('@pagefind/default-ui');
120
129
  new PagefindUI({
121
130
  element: '#starlight__search',
@@ -124,6 +133,13 @@ const pagefindTranslations = {
124
133
  showImages: false,
125
134
  translations,
126
135
  showSubResults: true,
136
+ processResult: (result: { url: string; sub_results: Array<{ url: string }> }) => {
137
+ result.url = formatURL(result.url);
138
+ result.sub_results = result.sub_results.map((sub_result) => {
139
+ sub_result.url = formatURL(sub_result.url);
140
+ return sub_result;
141
+ });
142
+ },
127
143
  });
128
144
  });
129
145
  });
@@ -35,4 +35,36 @@
35
35
 
36
36
  export * from 'astro-expressive-code';
37
37
 
38
+ import type { StarlightExpressiveCodeOptions } from './index';
39
+
40
+ export type { StarlightExpressiveCodeOptions };
41
+
42
+ /**
43
+ * A utility function that helps you define an Expressive Code configuration object. It is meant
44
+ * to be used inside the optional config file `ec.config.mjs` located in the root directory
45
+ * of your Starlight project, and its return value to be exported as the default export.
46
+ *
47
+ * Expressive Code will automatically detect this file and use the exported configuration object
48
+ * to override its own default settings.
49
+ *
50
+ * Using this function is recommended, but not required. It just passes through the given object,
51
+ * but it also provides type information for your editor's auto-completion and type checking.
52
+ *
53
+ * @example
54
+ * ```js
55
+ * // ec.config.mjs
56
+ * import { defineEcConfig } from '@astrojs/starlight/expressive-code'
57
+ *
58
+ * export default defineEcConfig({
59
+ * themes: ['starlight-dark', 'github-light'],
60
+ * styleOverrides: {
61
+ * borderRadius: '0.5rem',
62
+ * },
63
+ * })
64
+ * ```
65
+ */
66
+ export function defineEcConfig(config: StarlightExpressiveCodeOptions) {
67
+ return config;
68
+ }
69
+
38
70
  export { getStarlightEcConfigPreprocessor } from './index';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/starlight",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "description": "Build beautiful, high-performance documentation websites with Astro",
5
5
  "keywords": [
6
6
  "docs",
package/style/props.css CHANGED
@@ -87,8 +87,8 @@
87
87
  'Segoe UI Symbol', 'Noto Color Emoji';
88
88
  --sl-font-system-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono',
89
89
  'Courier New', monospace;
90
- --__sl-font: var(--sl-font, ''), var(--sl-font-system);
91
- --__sl-font-mono: var(--sl-font-mono, ''), var(--sl-font-system-mono);
90
+ --__sl-font: var(--sl-font, var(--sl-font-system)), var(--sl-font-system);
91
+ --__sl-font-mono: var(--sl-font-mono, var(--sl-font-system-mono)), var(--sl-font-system-mono);
92
92
 
93
93
  /** Key layout values */
94
94
  --sl-nav-height: 3.5rem;