1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
| import { QuartzTransformerPlugin } from "../types"
| import rehypePrettyCode, { Options as CodeOptions, Theme as CodeTheme } from "rehype-pretty-code"
|
| interface Theme extends Record<string, CodeTheme> {
| light: CodeTheme
| dark: CodeTheme
| }
|
| interface Options {
| theme?: Theme
| keepBackground?: boolean
| }
|
| const defaultOptions: Options = {
| theme: {
| light: "github-light",
| dark: "github-dark",
| },
| keepBackground: false,
| }
|
| export const SyntaxHighlighting: QuartzTransformerPlugin<Partial<Options>> = (userOpts) => {
| const opts: CodeOptions = { ...defaultOptions, ...userOpts }
|
| return {
| name: "SyntaxHighlighting",
| htmlPlugins() {
| return [[rehypePrettyCode, opts]]
| },
| }
| }
|
|