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
Copy file name to clipboardExpand all lines: src/content/docs/en/guides/upgrade-to/v6.mdx
+128-2Lines changed: 128 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -420,13 +420,14 @@ The following experimental flags have been removed and **their corresponding fea
420
420
421
421
Remove these experimental flags from your Astro config if you were previously using them:
422
422
423
-
```js del={5-6} title="astro.config.mjs"
423
+
```js del={5-7} title="astro.config.mjs"
424
424
import { defineConfig } from'astro/config';
425
425
426
426
exportdefaultdefineConfig({
427
427
experimental: {
428
428
preserveScriptOrder:true,
429
429
staticImportMetaEnv:true,
430
+
headingIdCompat:true,
430
431
},
431
432
})
432
433
```
@@ -536,7 +537,7 @@ Review your links to your custom endpoints that include a file extension in the
536
537
537
538
<SourcePRnumber="14485"title="feat: stabilize static import meta env"/>
538
539
539
-
In Astro 5.13, the `experimental.staticImportMetaEnv` was introduced to update the behavior when accessing `import.meta.env` directly to align with [Vite's handling of environment variables](https://vite.dev/guide/env-and-mode.html#env-variables) and ensures that `import.meta.env` values are always inlined.
540
+
In Astro 5.13, the `experimental.staticImportMetaEnv`flag was introduced to update the behavior when accessing `import.meta.env` directly to align with [Vite's handling of environment variables](https://vite.dev/guide/env-and-mode.html#env-variables) and ensures that `import.meta.env` values are always inlined.
540
541
541
542
In Astro 5.x, non-public environment variables were replaced by a reference to `process.env`. Additionally, Astro could also convert the value type of your environment variables used through `import.meta.env`, which could prevent access to some values such as the strings `"true"` (which was converted to a boolean value), and `"1"` (which was converted to a number).
542
543
@@ -585,6 +586,131 @@ If you need more control over environment variables in Astro, we recommend you u
585
586
586
587
<ReadMore>Learn more about [environment variables](/en/guides/environment-variables/) in Astro, including `astro:env`.</ReadMore>
587
588
589
+
### Changed: Markdown heading ID generation
590
+
591
+
<SourcePRnumber="14494"title="feat!: stabilize experimental.headingIdCompat"/>
592
+
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.
594
+
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.
596
+
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.
598
+
599
+
#### What should I do?
600
+
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`:
608
+
609
+
```html ins="-"
610
+
<h2id="picture-"><code><Picture /></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:
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.
640
+
641
+
<details>
642
+
643
+
<summary>Create a custom rehype plugin to strip trailing hyphens</summary>
644
+
645
+
<Steps>
646
+
647
+
1. Install required dependencies:
648
+
649
+
<PackageManagerTabs>
650
+
<Fragmentslot="npm">
651
+
```sh
652
+
npm i github-slugger hast-util-heading-rank unist-util-visit hast-util-to-string
<ReadMore>Learn more about [Heading IDs](/en/guides/markdown-content/#heading-ids).</ReadMore>
713
+
588
714
## Community Resources
589
715
590
716
Know a good resource for Astro v5.0? [Edit this page](https://github.com/withastro/docs/edit/main/src/content/docs/en/guides/upgrade-to/v6.mdx) and add a link below!
0 commit comments