Skip to content

Commit

Permalink
Add markdown-it-anchor and permalinks
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Feb 27, 2024
1 parent 537c7f6 commit 88a5c0d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
18 changes: 18 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions src/assets/styles/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions vite.config.markdown.ts
Original file line number Diff line number Diff line change
@@ -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']
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 88a5c0d

Please sign in to comment.