feat: add citations transformer plugin

This commit is contained in:
linozen 2024-03-10 11:12:56 +01:00
parent 3880e58912
commit a3fc2aa40a
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,33 @@
import rehypeCitation from "rehype-citation"
import { QuartzTransformerPlugin } from "../types"
export interface Options {
bibliographyFile: string
suppressBibliography: boolean
}
const defaultOptions: Options = {
bibliographyFile: "./bibliography.bib",
suppressBibliography: false,
}
export const Citations: QuartzTransformerPlugin<Partial<Options> | undefined> = (userOpts) => {
const opts = { ...defaultOptions, ...userOpts }
return {
name: "Citations",
htmlPlugins() {
return [
[
rehypeCitation,
{
bibliography: opts.bibliographyFile,
suppressBibliography: opts.suppressBibliography,
// Until popovers are implemented to not show for citation links, I
// don't want to link citations
linkCitations: false,
},
],
]
},
}
}

View File

@ -1,5 +1,6 @@
export { FrontMatter } from "./frontmatter" export { FrontMatter } from "./frontmatter"
export { GitHubFlavoredMarkdown } from "./gfm" export { GitHubFlavoredMarkdown } from "./gfm"
export { Citations } from "./citations"
export { CreatedModifiedDate } from "./lastmod" export { CreatedModifiedDate } from "./lastmod"
export { Latex } from "./latex" export { Latex } from "./latex"
export { Description } from "./description" export { Description } from "./description"