diff --git a/package-lock.json b/package-lock.json index 02d95d8..9ec2143 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,7 @@ "autoprefixer": "^10.4.17", "js-yaml": "^4.1.0", "markdown-it": "^14.0.0", + "markdown-it-anchor": "^8.6.7", "markdown-it-container": "^4.0.0", "markdown-it-prism": "^2.3.0", "postcss": "^8.4.35", @@ -2335,6 +2336,16 @@ "markdown-it": "bin/markdown-it.mjs" } }, + "node_modules/markdown-it-anchor": { + "version": "8.6.7", + "resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-8.6.7.tgz", + "integrity": "sha512-FlCHFwNnutLgVTflOYHPW2pPcl2AACqVzExlkGQNsi4CJgqOHN7YTgDd4LuhgN1BFO3TS0vLAruV1Td6dwWPJA==", + "dev": true, + "peerDependencies": { + "@types/markdown-it": "*", + "markdown-it": "*" + } + }, "node_modules/markdown-it-container": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/markdown-it-container/-/markdown-it-container-4.0.0.tgz", @@ -5392,6 +5403,13 @@ "uc.micro": "^2.0.0" } }, + "markdown-it-anchor": { + "version": "8.6.7", + "resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-8.6.7.tgz", + "integrity": "sha512-FlCHFwNnutLgVTflOYHPW2pPcl2AACqVzExlkGQNsi4CJgqOHN7YTgDd4LuhgN1BFO3TS0vLAruV1Td6dwWPJA==", + "dev": true, + "requires": {} + }, "markdown-it-container": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/markdown-it-container/-/markdown-it-container-4.0.0.tgz", diff --git a/package.json b/package.json index 0488415..2633200 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "autoprefixer": "^10.4.17", "js-yaml": "^4.1.0", "markdown-it": "^14.0.0", + "markdown-it-anchor": "^8.6.7", "markdown-it-container": "^4.0.0", "markdown-it-prism": "^2.3.0", "postcss": "^8.4.35", diff --git a/src/assets/styles/index.css b/src/assets/styles/index.css index 7a1ddbb..9104ec4 100644 --- a/src/assets/styles/index.css +++ b/src/assets/styles/index.css @@ -72,6 +72,10 @@ code[class*=language-], pre[class*=language-] { background-color:#1f2937; min-width: fit-content; } +.prose h1>a, .prose h2>a, .prose h3>a, .prose h4>a, .prose h5>a, .prose h6>a { + color: inherit; + text-decoration: none; +} /* dark mode autocomplete fields */ .dark input:-webkit-autofill, diff --git a/vite.config.markdown.ts b/vite.config.markdown.ts index d76b834..0bcc377 100644 --- a/vite.config.markdown.ts +++ b/vite.config.markdown.ts @@ -1,6 +1,7 @@ import MarkdownIt from "markdown-it" import container from "markdown-it-container" import prism from "markdown-it-prism" +import anchor from "markdown-it-anchor" import Prism from 'prismjs' const FencedComponents = ['files'] @@ -73,6 +74,7 @@ export default function(md:MarkdownIt, options: { fencedComponents?:string[] } = } md.linkify.set({ fuzzyLink: false }) + md.use(anchor, {permalink: anchor.permalink.headerLink()}) md.use(prism) md.use((md:any) => { const allComponents = [...(options.fencedComponents || []), ...FencedComponents]