feat: add headings
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user