@astrojs/starlight 0.38.0 → 0.38.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.38.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#3751](https://github.com/withastro/starlight/pull/3751) [`fb955ff`](https://github.com/withastro/starlight/commit/fb955ff39c3244edf808495c557fb84ce2aab260) Thanks [@pyxelr](https://github.com/pyxelr)! - Fixes a regression causing global `tableOfContents` config to be ignored
8
+
3
9
  ## 0.38.0
4
10
 
5
11
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/starlight",
3
- "version": "0.38.0",
3
+ "version": "0.38.1",
4
4
  "description": "Build beautiful, high-performance documentation websites with Astro",
5
5
  "keywords": [
6
6
  "docs",
package/schema.ts CHANGED
@@ -2,7 +2,7 @@ import { z } from 'astro/zod';
2
2
  import type { SchemaContext } from 'astro:content';
3
3
  import { HeadConfigSchema } from './schemas/head';
4
4
  import { PrevNextLinkConfigSchema } from './schemas/prevNextLink';
5
- import { TableOfContentsSchema } from './schemas/tableOfContents';
5
+ import { FrontmatterTableOfContentsSchema } from './schemas/tableOfContents';
6
6
  import { BadgeConfigSchema } from './schemas/badge';
7
7
  import { HeroSchema } from './schemas/hero';
8
8
  import { SidebarLinkItemHTMLAttributesSchema } from './schemas/sidebar';
@@ -33,7 +33,7 @@ const StarlightFrontmatterSchema = (context: SchemaContext) =>
33
33
  head: HeadConfigSchema({ source: 'content' }),
34
34
 
35
35
  /** Override global table of contents configuration for this page. */
36
- tableOfContents: TableOfContentsSchema().optional(),
36
+ tableOfContents: FrontmatterTableOfContentsSchema(),
37
37
 
38
38
  /**
39
39
  * Set the layout style for this page.
@@ -2,18 +2,20 @@ import { z } from 'astro/zod';
2
2
 
3
3
  const defaults = { minHeadingLevel: 2, maxHeadingLevel: 3 };
4
4
 
5
- export const TableOfContentsSchema = () =>
6
- z
7
- .union([
8
- z.object({
9
- /** The level to start including headings at in the table of contents. Default: 2. */
10
- minHeadingLevel: z.int().min(1).max(6).optional().default(2),
11
- /** The level to stop including headings at in the table of contents. Default: 3. */
12
- maxHeadingLevel: z.int().min(1).max(6).optional().default(3),
13
- }),
14
- z.boolean().transform((enabled) => (enabled ? defaults : false)),
15
- ])
16
- .default(defaults)
17
- .refine((toc) => (toc ? toc.minHeadingLevel <= toc.maxHeadingLevel : true), {
18
- error: 'minHeadingLevel must be less than or equal to maxHeadingLevel',
19
- });
5
+ const TableOfContentsBaseSchema = z
6
+ .union([
7
+ z.object({
8
+ /** The level to start including headings at in the table of contents. Default: 2. */
9
+ minHeadingLevel: z.int().min(1).max(6).optional().default(2),
10
+ /** The level to stop including headings at in the table of contents. Default: 3. */
11
+ maxHeadingLevel: z.int().min(1).max(6).optional().default(3),
12
+ }),
13
+ z.boolean().transform((enabled) => (enabled ? defaults : false)),
14
+ ])
15
+ .refine((toc) => (toc ? toc.minHeadingLevel <= toc.maxHeadingLevel : true), {
16
+ error: 'minHeadingLevel must be less than or equal to maxHeadingLevel',
17
+ });
18
+
19
+ export const UserConfigTableOfContentsSchema = () => TableOfContentsBaseSchema.default(defaults);
20
+
21
+ export const FrontmatterTableOfContentsSchema = () => TableOfContentsBaseSchema.optional();
@@ -9,7 +9,7 @@ import { PagefindConfigDefaults, PagefindConfigSchema } from '../schemas/pagefin
9
9
  import { SidebarItemSchema } from '../schemas/sidebar';
10
10
  import { TitleConfigSchema, TitleTransformConfigSchema } from '../schemas/site-title';
11
11
  import { SocialLinksSchema } from '../schemas/social';
12
- import { TableOfContentsSchema } from '../schemas/tableOfContents';
12
+ import { UserConfigTableOfContentsSchema } from '../schemas/tableOfContents';
13
13
  import { BuiltInDefaultLocale } from './i18n';
14
14
 
15
15
  const LocaleSchema = z.object({
@@ -49,7 +49,7 @@ const UserConfigSchema = z.object({
49
49
  tagline: z.string().optional(),
50
50
 
51
51
  /** Configure the defaults for the table of contents on each page. */
52
- tableOfContents: TableOfContentsSchema(),
52
+ tableOfContents: UserConfigTableOfContentsSchema(),
53
53
 
54
54
  /** Enable and configure “Edit this page” links. */
55
55
  editLink: z