From 9fe22ea6481754a4d68d9f01beb2c26412a2eb07 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sun, 23 Oct 2022 02:10:32 +0300 Subject: feat: autolink headings --- package.json | 2 ++ src/pages/[...path].tsx | 5 ++++- yarn.lock | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index fe6f347..fd93f65 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,8 @@ "react-dom": "18.2.0", "react-markdown": "^8.0.3", "react-syntax-highlighter": "^15.5.0", + "rehype-autolink-headings": "^6.1.1", + "rehype-slug": "^5.0.1", "remark-gemoji": "^7.0.1", "remark-gfm": "^3.0.1", "unist-util-visit-parents": "^5.1.1" diff --git a/src/pages/[...path].tsx b/src/pages/[...path].tsx index 06ad09d..d37ec91 100644 --- a/src/pages/[...path].tsx +++ b/src/pages/[...path].tsx @@ -9,6 +9,8 @@ import remarkGemoji from 'remark-gemoji'; import benzinConfig from '../config'; import Code from '../Code'; import remarkGfm from 'remark-gfm'; +import rehypeSlug from 'rehype-slug'; +import rehypeAutolinkHeadings from 'rehype-autolink-headings'; const transformLinkUri = (uri: string): string => { return uri.match(/(.*)\.md/)?.[1] || uri; @@ -65,7 +67,8 @@ const Page: NextPage = ({ markdownSource, emojiFileNames }: any) => {