You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds support for generating clickable anchor links for headings.
6
+
7
+
By default, Starlight now renders an anchor link beside headings in Markdown and MDX content. A new `<AnchorHeading>` component is available to achieve the same thing in custom pages built using `<StarlightPage>`.
8
+
9
+
If you want to disable this new Markdown processing set the `markdown.headingLinks` option in your Starlight config to `false`:
10
+
11
+
```js
12
+
starlight({
13
+
title:'My docs',
14
+
markdown: {
15
+
headingLinks:false,
16
+
},
17
+
}),
18
+
```
19
+
20
+
⚠️ **BREAKING CHANGE:** The minimum supported version of Astro is now v5.5.0.
Copy file name to clipboardExpand all lines: docs/src/content/docs/guides/authoring-content.mdx
+19Lines changed: 19 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -650,3 +650,22 @@ If you already have a Starlight site and want to add Markdoc, follow these steps
650
650
</Steps>
651
651
652
652
To learn more about the Markdoc syntax and features, see the [Markdoc documentation](https://markdoc.dev/docs/syntax) or the [Astro Markdoc integration guide](https://docs.astro.build/en/guides/integrations-guide/markdoc/).
653
+
654
+
### Configuring the Markdoc preset
655
+
656
+
The `starlightMarkdoc()` preset accepts the following configuration options:
657
+
658
+
#### `headingLinks`
659
+
660
+
**type:**`boolean`
661
+
**default:**`true`
662
+
663
+
Controls whether or not headings are rendered with a clickable anchor link.
664
+
Equivalent to the [`markdown.headingLinks`](/reference/configuration/#markdown) option, which applies to Markdown and MDX files.
665
+
666
+
```js "headingLinks: false"
667
+
exportdefaultdefineMarkdocConfig({
668
+
// Disable the default heading anchor link support
Copy file name to clipboardExpand all lines: docs/src/content/docs/guides/pages.mdx
+56-3Lines changed: 56 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,8 @@ title: Pages
3
3
description: Learn how to create and manage your documentation site’s pages with Starlight.
4
4
sidebar:
5
5
order: 1
6
+
tableOfContents:
7
+
maxHeadingLevel: 4
6
8
---
7
9
8
10
Starlight generates your site’s HTML pages based on your content, with flexible options provided via Markdown frontmatter.
@@ -73,28 +75,49 @@ Read more in the [“Pages” guide in the Astro docs](https://docs.astro.build/
73
75
74
76
### Using Starlight’s design in custom pages
75
77
76
-
To use the Starlight layout in custom pages, wrap your page content with the `<StarlightPage />` component.
78
+
To use the Starlight layout in custom pages, wrap your page content with the [`<StarlightPage>` component](#starlightpage-component).
77
79
This can be helpful if you are generating content dynamically but still want to use Starlight’s design.
78
80
81
+
To add anchor links to headings that match Starlight’s Markdown anchor link styles, you can use the [`<AnchorHeading>` component](#anchorheading-component) in your custom pages.
82
+
79
83
```astro
80
84
---
81
85
// src/pages/custom-page/example.astro
82
86
import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro';
87
+
import AnchorHeading from '@astrojs/starlight/components/AnchorHeading.astro';
83
88
import CustomComponent from './CustomComponent.astro';
It accepts the following props as well as any other valid [global HTML attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes).
213
+
214
+
##### `level`
215
+
216
+
**required**
217
+
**type:**`1 | 2 | 3 | 4 | 5 | 6`
218
+
219
+
The heading level to render.
220
+
For example, `level="1"` would render an `<h1>` element.
221
+
222
+
##### `id`
223
+
224
+
**required**
225
+
**type:**`string`
226
+
227
+
The unique ID for this heading.
228
+
This will be used as the `id` attribute of the rendered heading and the anchor icon will link to it.
0 commit comments