Skip to content

Commit 754ac7b

Browse files
author
Michał Gryczka
committed
Added rehype plugins for external links and slug generation in markdown; updated package manager version and added new dependencies.
1 parent b76cf05 commit 754ac7b

3 files changed

Lines changed: 85 additions & 3 deletions

File tree

astro.config.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import react from "@astrojs/react";
1212
import sitemap from "@astrojs/sitemap";
1313

1414
import partytown from "@astrojs/partytown";
15+
import rehypeExternalLinks from "rehype-external-links";
16+
import rehypeSlug from "rehype-slug";
1517

1618
const __filename = fileURLToPath(import.meta.url);
1719

@@ -49,8 +51,9 @@ export default defineConfig({
4951
],
5052
markdown: {
5153
rehypePlugins: [
52-
// Keep string-based configuration which works with both versions
53-
['rehype-external-links', {
54+
// Add id attributes to headings (h1-h6) for direct section linking
55+
rehypeSlug,
56+
[rehypeExternalLinks, {
5457
target: "_blank",
5558
rel: ["nofollow", "noopener", "noreferrer"],
5659
}],

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"eslint:lint": "eslint src/**/*.{ts,tsx,astro} --max-warnings 0",
1616
"lint": "pnpm prettier:lint && pnpm tsc && pnpm eslint:lint && pnpm astro check"
1717
},
18-
"packageManager": "pnpm@9.14.2",
18+
"packageManager": "pnpm@10.32.1",
1919
"pnpm": {
2020
"default": "9.14.2"
2121
},
@@ -46,11 +46,13 @@
4646
"react-slick": "^0.30.3",
4747
"rehype-external-links": "^2.1.0",
4848
"rehype-raw": "^7.0.0",
49+
"rehype-slug": "^6.0.0",
4950
"sass": "^1.89.2",
5051
"sharp": "0.34.0",
5152
"shiki": "^3.8.1",
5253
"short-unique-id": "^5.3.2",
5354
"slick-carousel": "^1.8.1",
55+
"stream-replace-string": "^2.0.0",
5456
"typescript": "^5.8.3",
5557
"unified": "^11.0.5",
5658
"use-breakpoint": "^4.0.6",

0 commit comments

Comments
 (0)