upgrade rehype-citation nextjs tailwindcss

This commit is contained in:
Timothy Lin
2022-01-31 18:22:57 +08:00
parent e2e8cb00f2
commit 2a62c0996e
5 changed files with 489 additions and 17647 deletions

View File

@ -9,6 +9,7 @@ import getAllFilesRecursively from './utils/files'
import remarkGfm from 'remark-gfm'
import remarkFootnotes from 'remark-footnotes'
import remarkMath from 'remark-math'
import remarkExtractFrontmatter from './remark-extract-frontmatter'
import remarkCodeTitles from './remark-code-title'
import remarkTocHeadings from './remark-toc-headings'
import remarkImgToJsx from './remark-img-to-jsx'
@ -67,6 +68,7 @@ export async function getFileBySlug(type, slug) {
// plugins in the future.
options.remarkPlugins = [
...(options.remarkPlugins ?? []),
remarkExtractFrontmatter,
[remarkTocHeadings, { exportRef: toc }],
remarkGfm,
remarkCodeTitles,
@ -79,10 +81,7 @@ export async function getFileBySlug(type, slug) {
rehypeSlug,
rehypeAutolinkHeadings,
rehypeKatex,
[
rehypeCitation,
{ bibliography: frontmatter?.bibliography, path: path.join(root, 'data') },
],
[rehypeCitation, { path: path.join(root, 'data') }],
[rehypePrismPlus, { ignoreMissing: true }],
rehypePresetMinify,
]

View File

@ -0,0 +1,10 @@
import { visit } from 'unist-util-visit'
import { load } from 'js-yaml'
export default function extractFrontmatter() {
return (tree, file) => {
visit(tree, 'yaml', (node, index, parent) => {
file.data.frontmatter = load(node.value)
})
}
}