@astrojs/starlight 0.31.0 → 0.31.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,11 @@
1
1
  # @astrojs/starlight
2
2
 
3
+ ## 0.31.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2805](https://github.com/withastro/starlight/pull/2805) [`ed6f9fd`](https://github.com/withastro/starlight/commit/ed6f9fd77334c02a75240087d0800ef32f159583) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Exposes the [`StarlightIcon`](https://starlight.astro.build/reference/icons/#starlighticon-type) TypeScript type referencing the names of Starlight’s built-in icons.
8
+
3
9
  ## 0.31.0
4
10
 
5
11
  ### Minor Changes
@@ -1,9 +1,9 @@
1
1
  ---
2
- import { Icons } from '../components/Icons';
2
+ import type { StarlightIcon } from '../components/Icons';
3
3
  import Icon from '../user-components/Icon.astro';
4
4
 
5
5
  interface Props {
6
- icon: keyof typeof Icons;
6
+ icon: StarlightIcon;
7
7
  label: string;
8
8
  }
9
9
 
@@ -185,3 +185,5 @@ export const Icons = {
185
185
  ...BuiltInIcons,
186
186
  ...FileIcons,
187
187
  };
188
+
189
+ export type StarlightIcon = keyof typeof Icons;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/starlight",
3
- "version": "0.31.0",
3
+ "version": "0.31.1",
4
4
  "description": "Build beautiful, high-performance documentation websites with Astro",
5
5
  "keywords": [
6
6
  "docs",
@@ -178,10 +178,10 @@
178
178
  "@astrojs/markdown-remark": "^6.0.1",
179
179
  "@playwright/test": "^1.45.0",
180
180
  "@types/node": "^18.16.19",
181
- "@vitest/coverage-v8": "2.1.6",
181
+ "@vitest/coverage-v8": "^3.0.1",
182
182
  "astro": "^5.1.5",
183
183
  "linkedom": "^0.18.4",
184
- "vitest": "2.1.6"
184
+ "vitest": "^3.0.1"
185
185
  },
186
186
  "dependencies": {
187
187
  "@astrojs/mdx": "^4.0.5",
package/schemas/hero.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  import { z } from 'astro/zod';
2
2
  import type { SchemaContext } from 'astro:content';
3
- import { Icons } from '../components/Icons';
3
+ import { Icons, type StarlightIcon } from '../components/Icons';
4
4
 
5
- type IconName = keyof typeof Icons;
6
- const iconNames = Object.keys(Icons) as [IconName, ...IconName[]];
5
+ const iconNames = Object.keys(Icons) as [StarlightIcon, ...StarlightIcon[]];
7
6
 
8
7
  export const HeroSchema = ({ image }: SchemaContext) =>
9
8
  z.object({
package/types.ts CHANGED
@@ -3,3 +3,4 @@ export type {
3
3
  StarlightPlugin,
4
4
  StarlightUserConfigWithPlugins as StarlightUserConfig,
5
5
  } from './utils/plugins';
6
+ export type { StarlightIcon } from './components/Icons';
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  import Icon from './Icon.astro';
3
- import type { Icons } from '../components/Icons';
3
+ import type { StarlightIcon } from '../components/Icons';
4
4
 
5
5
  interface Props {
6
- icon?: keyof typeof Icons;
6
+ icon?: StarlightIcon;
7
7
  title: string;
8
8
  }
9
9
 
@@ -1,8 +1,8 @@
1
1
  ---
2
- import { Icons } from '../components/Icons';
2
+ import { Icons, type StarlightIcon } from '../components/Icons';
3
3
 
4
4
  interface Props {
5
- name: keyof typeof Icons;
5
+ name: StarlightIcon;
6
6
  label?: string;
7
7
  color?: string;
8
8
  size?: string;
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  import type { HTMLAttributes } from 'astro/types';
3
- import { Icons } from '../components/Icons';
3
+ import type { StarlightIcon } from '../components/Icons';
4
4
  import Icon from './Icon.astro';
5
5
 
6
6
  interface Props extends Omit<HTMLAttributes<'a'>, 'href'> {
7
7
  href: string | URL;
8
- icon?: keyof typeof Icons | undefined;
8
+ icon?: StarlightIcon | undefined;
9
9
  iconPlacement?: 'start' | 'end' | undefined;
10
10
  variant?: 'primary' | 'secondary' | 'minimal';
11
11
  }
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  import { TabItemTagname } from './rehype-tabs';
3
- import type { Icons } from '../components/Icons';
3
+ import type { StarlightIcon } from '../components/Icons';
4
4
 
5
5
  interface Props {
6
- icon?: keyof typeof Icons;
6
+ icon?: StarlightIcon;
7
7
  label: string;
8
8
  }
9
9
 
@@ -6,7 +6,7 @@ import { fromHtml } from 'hast-util-from-html';
6
6
  import { toString } from 'hast-util-to-string';
7
7
  import { rehype } from 'rehype';
8
8
  import { CONTINUE, SKIP, visit } from 'unist-util-visit';
9
- import { Icons } from '../components/Icons';
9
+ import { Icons, type StarlightIcon } from '../components/Icons';
10
10
  import { definitions } from './file-tree-icons';
11
11
 
12
12
  declare module 'vfile' {
@@ -160,7 +160,7 @@ function getFileIcon(fileName: string) {
160
160
  const name = getFileIconName(fileName);
161
161
  if (!name) return defaultFileIcon;
162
162
  if (name in Icons) {
163
- const path = Icons[name as keyof typeof Icons];
163
+ const path = Icons[name as StarlightIcon];
164
164
  return makeSVGIcon(path);
165
165
  }
166
166
  return defaultFileIcon;
@@ -2,13 +2,13 @@ import type { Element } from 'hast';
2
2
  import { select } from 'hast-util-select';
3
3
  import { rehype } from 'rehype';
4
4
  import { CONTINUE, SKIP, visit } from 'unist-util-visit';
5
- import { Icons } from '../components/Icons';
5
+ import type { StarlightIcon } from '../components/Icons';
6
6
 
7
7
  interface Panel {
8
8
  panelId: string;
9
9
  tabId: string;
10
10
  label: string;
11
- icon?: keyof typeof Icons;
11
+ icon?: StarlightIcon;
12
12
  }
13
13
 
14
14
  declare module 'vfile' {
@@ -67,7 +67,7 @@ const tabsProcessor = rehype()
67
67
  ...ids,
68
68
  label: String(dataLabel),
69
69
  };
70
- if (dataIcon) panel.icon = String(dataIcon) as keyof typeof Icons;
70
+ if (dataIcon) panel.icon = String(dataIcon) as StarlightIcon;
71
71
  file.data.panels?.push(panel);
72
72
 
73
73
  // Remove `<TabItem>` props