feat: add headings

This commit is contained in:
DIYgod
2022-10-03 18:39:19 +01:00
parent 5ba43d179f
commit abd488c972
4 changed files with 134 additions and 0 deletions
+16
View File
@@ -18,6 +18,22 @@
@apply mb-0;
}
.prose .xlog-anchor {
@apply pr-1 -ml-5 text-base align-middle hidden;
}
.prose .xlog-anchor > span {
@apply inline-block text-zinc-900;
}
.prose h2:hover .xlog-anchor,
.prose h3:hover .xlog-anchor,
.prose h4:hover .xlog-anchor,
.prose h5:hover .xlog-anchor,
.prose h6:hover .xlog-anchor {
@apply inline;
}
.prose h2 {
@apply text-3xl font-semibold;
@apply my-7;
+18
View File
@@ -22,6 +22,8 @@ import remarkDirective from "remark-directive"
import remarkDirectiveRehype from "remark-directive-rehype"
import { remarkYoutube } from "./remark-youtube"
import sanitizeScheme from "./sanitize-schema"
import rehypeSlug from "rehype-slug"
import rehypeAutolinkHeadings from "rehype-autolink-headings"
export type MarkdownEnv = {
excerpt: string
@@ -85,6 +87,22 @@ export const renderPageContent = (
.use(rehypeTable)
.use(rehypeExternalLink)
.use(rehypeWrapCode)
.use(rehypeSlug)
.use(rehypeAutolinkHeadings, {
properties: {
className: ["xlog-anchor"],
ariaHidden: true,
tabIndex: -1,
},
content: {
type: "element",
tagName: "span",
properties: {
className: ["i-akar-icons:link-chain"],
},
children: [],
},
})
.use(html ? () => (tree: any) => {} : rehypeReact, {
createElement: createElement,
components: {