Skip to content

Commit 7fef5f8

Browse files
Apply suggestions from code review
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
1 parent 0ac087f commit 7fef5f8

File tree

1 file changed

+25
-18
lines changed
  • src/content/docs/en/guides/upgrade-to

1 file changed

+25
-18
lines changed

src/content/docs/en/guides/upgrade-to/v6.mdx

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -590,17 +590,35 @@ If you need more control over environment variables in Astro, we recommend you u
590590

591591
<SourcePR number="14494" title="feat!: stabilize experimental.headingIdCompat"/>
592592

593-
In Astro 5.5, the `experimental.headingIdCompat` flag was introduced to make the IDs generated by Astro for Markdown headings compatible with common platforms like GitHub and npm, using the popular [`github-slugger`](https://github.com/Flet/github-slugger) package.
593+
In Astro 5.x, an additional default processing step to Markdown stripped trailing hyphens from the end of IDs for section headings ending in special characters. This provided a cleaner `id` value, but could lead to incompatibilities rendering your Markdown across platforms.
594594

595-
In Astro 5.x, Astro had an additional default processing step that stripped trailing hyphens from the end of IDs for headings ending in special characters.
595+
In Astro 5.5, the `experimental.headingIdCompat` flag was introduced to allow you to make the IDs generated by Astro for Markdown headings compatible with common platforms like GitHub and npm, using the popular [`github-slugger`](https://github.com/Flet/github-slugger) package.
596596

597-
Astro 6.0 removes this experimental flag and makes this the new default behavior in Astro: trailing hyphens from the end of IDs for headings ending in special characters aren't stripped anymore.
597+
Astro 6.0 removes this experimental flag and makes this the new default behavior in Astro: trailing hyphens from the end of IDs for headings ending in special characters are no longer removed.
598598

599599
#### What should I do?
600600

601-
If you were previously using this experimental feature, you must [remove this experimental flag from your configuration](#experimental-flags) as it no longer exists.
601+
If you have manual links to headings, you may need to update the anchor link value with a new trailing hyphen. For example, the following Markdown heading:
602+
603+
```md
604+
## `<Picture />`
605+
```
606+
607+
will now generate the following HTML with a trailing hyphen in the heading `id`:
602608

603-
If you were previously using the `rehypeHeadingIds` plugin directly, remove the `headingIdCompat` option as it no longer exists:
609+
```html ins="-"
610+
<h2 id="picture-"><code>&lt;Picture /&gt;</h2>
611+
```
612+
613+
and must now be linked to as:
614+
615+
```markdown ins="-"
616+
See [the Picture component](/en/guides/images/#picture-) for more details.
617+
```
618+
619+
If you were previously using the experimental feature to enforce trailing hyphens, you must [remove this experimental flag from your configuration](#experimental-flags) as it no longer exists.
620+
621+
If you were previously using the `rehypeHeadingIds` plugin directly to enforce compatibility, remove the `headingIdCompat` option as it no longer exists:
604622

605623
```js title="astro.config.mjs" del={8} ins={9}
606624
import { defineConfig } from 'astro/config';
@@ -618,22 +636,11 @@ export default defineConfig({
618636
});
619637
```
620638

621-
If you have manual links to headings, review them to make sure they're still correct. For example, the following Markdown heading:
622-
623-
```md
624-
## `<Picture />`
625-
```
626-
627-
will generate the following HTML:
628-
629-
```html del={1} ins={2}
630-
<h2 id="picture"><code>&lt;Picture /&gt;</h2>
631-
<h2 id="picture-"><code>&lt;Picture /&gt;</h2>
632-
```
639+
If you want to keep the old ID generation for backward compatibility reasons, you can create a custom rehype plugin that will generate headings IDs like Astro 5.x. This will allow you to continue to use your existing anchor links without adding trailing hyphens.
633640

634641
<details>
635642

636-
<summary>If you want to keep the old ID generation for backward compatibility reasons, you can create a custom rehype plugin that will generate headings IDs like Astro 5.x. Click to expand.</summary>
643+
<summary>Create a custom rehype plugin to strip trailing hyphens</summary>
637644

638645
<Steps>
639646

0 commit comments

Comments
 (0)