Skip to content

Commit 6873a1d

Browse files
authored
Merge pull request #368 from timlrx/upgrade/rehype-citation
upgrade rehype-citation, nextjs, tailwindcss
2 parents ebbe94a + 2a62c09 commit 6873a1d

File tree

5 files changed

+506
-17664
lines changed

5 files changed

+506
-17664
lines changed

css/prism.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
}
2121

2222
.code-line {
23-
@apply block pl-4 pr-4 -mx-4 border-l-4 border-opacity-0;
23+
@apply block pl-4 pr-4 -mx-4 border-l-4 border-transparent;
2424
}
2525

2626
.code-line.inserted {

lib/mdx.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import getAllFilesRecursively from './utils/files'
99
import remarkGfm from 'remark-gfm'
1010
import remarkFootnotes from 'remark-footnotes'
1111
import remarkMath from 'remark-math'
12+
import remarkExtractFrontmatter from './remark-extract-frontmatter'
1213
import remarkCodeTitles from './remark-code-title'
1314
import remarkTocHeadings from './remark-toc-headings'
1415
import remarkImgToJsx from './remark-img-to-jsx'
@@ -67,6 +68,7 @@ export async function getFileBySlug(type, slug) {
6768
// plugins in the future.
6869
options.remarkPlugins = [
6970
...(options.remarkPlugins ?? []),
71+
remarkExtractFrontmatter,
7072
[remarkTocHeadings, { exportRef: toc }],
7173
remarkGfm,
7274
remarkCodeTitles,
@@ -79,10 +81,7 @@ export async function getFileBySlug(type, slug) {
7981
rehypeSlug,
8082
rehypeAutolinkHeadings,
8183
rehypeKatex,
82-
[
83-
rehypeCitation,
84-
{ bibliography: frontmatter?.bibliography, path: path.join(root, 'data') },
85-
],
84+
[rehypeCitation, { path: path.join(root, 'data') }],
8685
[rehypePrismPlus, { ignoreMissing: true }],
8786
rehypePresetMinify,
8887
]

lib/remark-extract-frontmatter.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { visit } from 'unist-util-visit'
2+
import { load } from 'js-yaml'
3+
4+
export default function extractFrontmatter() {
5+
return (tree, file) => {
6+
visit(tree, 'yaml', (node, index, parent) => {
7+
file.data.frontmatter = load(node.value)
8+
})
9+
}
10+
}

0 commit comments

Comments
 (0)