diff --git a/mdsvex.config.js b/mdsvex.config.js index 3587dc3..a720983 100644 --- a/mdsvex.config.js +++ b/mdsvex.config.js @@ -1,6 +1,8 @@ import { defineMDSveXConfig as defineConfig } from 'mdsvex'; import remarkGFM from 'remark-gfm'; import remarkEmoji from 'remark-emoji'; +import rehypeSlug from 'rehype-slug'; +import rehypeAutolinkHeadings from 'rehype-autolink-headings'; const config = defineConfig({ layout: { @@ -13,7 +15,7 @@ const config = defineConfig({ }, remarkPlugins: [remarkGFM, remarkEmoji], - rehypePlugins: [], + rehypePlugins: [rehypeSlug, rehypeAutolinkHeadings], }); export default config; diff --git a/package.json b/package.json index 15f9fe3..51a442c 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,8 @@ "postcss-normalize": "^10.0.1", "prettier": "^2.6.2", "prettier-plugin-svelte": "^2.7.0", + "rehype-autolink-headings": "^6.1.1", + "rehype-slug": "^5.0.1", "remark-emoji": "^3.0.2", "remark-gfm": "^3.0.1", "svelte": "^3.44.0", diff --git a/yarn.lock b/yarn.lock index ebbf4e8..a074c3a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -182,6 +182,13 @@ dependencies: "@types/ms" "*" +"@types/hast@^2.0.0": + version "2.3.4" + resolved "https://registry.yarnpkg.com/@types/hast/-/hast-2.3.4.tgz#8aa5ef92c117d20d974a82bdfb6a648b08c0bafc" + integrity sha512-wLEm0QvaoawEDoTRwzTXp4b4jpwiJDvR5KMnFnVodm3scufTlBOWRD6N1OBf9TZMhjlNsSfcO5V+7AF4+Vy+9g== + dependencies: + "@types/unist" "*" + "@types/json-schema@^7.0.9": version "7.0.11" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3" @@ -1013,6 +1020,11 @@ gauge@^3.0.0: strip-ansi "^6.0.1" wide-align "^1.1.2" +github-slugger@^1.1.1: + version "1.4.0" + resolved "https://registry.yarnpkg.com/github-slugger/-/github-slugger-1.4.0.tgz#206eb96cdb22ee56fdc53a28d5a302338463444e" + integrity sha512-w0dzqw/nt51xMVmlaV1+JRzN+oCa1KfcgGEWhxUG16wbdA+Xnt/yoFO8Z8x/V82ZcZ0wy6ln9QDup5avbhiDhQ== + glob-parent@^5.1.2, glob-parent@~5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" @@ -1090,6 +1102,33 @@ has@^1.0.3: dependencies: function-bind "^1.1.1" +hast-util-has-property@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/hast-util-has-property/-/hast-util-has-property-2.0.0.tgz#c15cd6180f3e535540739fcc9787bcffb5708cae" + integrity sha512-4Qf++8o5v14us4Muv3HRj+Er6wTNGA/N9uCaZMty4JWvyFKLdhULrv4KE1b65AthsSO9TXSZnjuxS8ecIyhb0w== + +hast-util-heading-rank@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/hast-util-heading-rank/-/hast-util-heading-rank-2.1.0.tgz#c39f34fa8330ebfec03a08b5d5019ed56122029c" + integrity sha512-w+Rw20Q/iWp2Bcnr6uTrYU6/ftZLbHKhvc8nM26VIWpDqDMlku2iXUVTeOlsdoih/UKQhY7PHQ+vZ0Aqq8bxtQ== + dependencies: + "@types/hast" "^2.0.0" + +hast-util-is-element@^2.0.0: + version "2.1.2" + resolved "https://registry.yarnpkg.com/hast-util-is-element/-/hast-util-is-element-2.1.2.tgz#fc0b0dc7cef3895e839b8d66979d57b0338c68f3" + integrity sha512-thjnlGAnwP8ef/GSO1Q8BfVk2gundnc2peGQqEg2kUt/IqesiGg/5mSwN2fE7nLzy61pg88NG6xV+UrGOrx9EA== + dependencies: + "@types/hast" "^2.0.0" + "@types/unist" "^2.0.0" + +hast-util-to-string@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/hast-util-to-string/-/hast-util-to-string-2.0.0.tgz#b008b0a4ea472bf34dd390b7eea1018726ae152a" + integrity sha512-02AQ3vLhuH3FisaMM+i/9sm4OXGSq1UhOOCpTLLQtHdL3tZt7qil69r8M8iDkZYyC0HCFylcYoP+8IO7ddta1A== + dependencies: + "@types/hast" "^2.0.0" + https-proxy-agent@^5.0.0: version "5.0.1" resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz#c59ef224a04fe8b754f3db0063a25ea30d0005d6" @@ -1946,6 +1985,32 @@ regexpp@^3.2.0: resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2" integrity sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg== +rehype-autolink-headings@^6.1.1: + version "6.1.1" + resolved "https://registry.yarnpkg.com/rehype-autolink-headings/-/rehype-autolink-headings-6.1.1.tgz#0cb874a56f3de6ead1c2268d7f0fc5006f244db5" + integrity sha512-NMYzZIsHM3sA14nC5rAFuUPIOfg+DFmf9EY1YMhaNlB7+3kK/ZlE6kqPfuxr1tsJ1XWkTrMtMoyHosU70d35mA== + dependencies: + "@types/hast" "^2.0.0" + extend "^3.0.0" + hast-util-has-property "^2.0.0" + hast-util-heading-rank "^2.0.0" + hast-util-is-element "^2.0.0" + unified "^10.0.0" + unist-util-visit "^4.0.0" + +rehype-slug@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/rehype-slug/-/rehype-slug-5.0.1.tgz#6e732d0c55b3b1e34187e74b7363fb53229e5f52" + integrity sha512-X5v3wV/meuOX9NFcGhJvUpEjIvQl2gDvjg3z40RVprYFt7q3th4qMmYLULiu3gXvbNX1ppx+oaa6JyY1W67pTA== + dependencies: + "@types/hast" "^2.0.0" + github-slugger "^1.1.1" + hast-util-has-property "^2.0.0" + hast-util-heading-rank "^2.0.0" + hast-util-to-string "^2.0.0" + unified "^10.0.0" + unist-util-visit "^4.0.0" + remark-emoji@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/remark-emoji/-/remark-emoji-3.0.2.tgz#786e88af1ecae682d74d7e1219989f34708205da"