feat: add citations transformer plugin
This commit is contained in:
parent
3880e58912
commit
a3fc2aa40a
33
quartz/plugins/transformers/citations.ts
Normal file
33
quartz/plugins/transformers/citations.ts
Normal 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,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
]
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
@ -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"
|
||||||
|
Loading…
Reference in New Issue
Block a user