From 285c0e9768db8db79a7262cbd5aafb186ab8ca8c Mon Sep 17 00:00:00 2001
From: catcodeme <1020082805@qq.com>
Date: Tue, 03 Dec 2024 06:50:50 +0000
Subject: [PATCH] docs(showcase): 8cat.life (#1617)
---
quartz/plugins/transformers/syntax.ts | 36 ++++++++++++++++++++++++++++--------
1 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/quartz/plugins/transformers/syntax.ts b/quartz/plugins/transformers/syntax.ts
index d2d0103..5d3aae0 100644
--- a/quartz/plugins/transformers/syntax.ts
+++ b/quartz/plugins/transformers/syntax.ts
@@ -1,11 +1,31 @@
import { QuartzTransformerPlugin } from "../types"
-import rehypePrettyCode, { Options as CodeOptions } from "rehype-pretty-code"
+import rehypePrettyCode, { Options as CodeOptions, Theme as CodeTheme } from "rehype-pretty-code"
-export const SyntaxHighlighting: QuartzTransformerPlugin = () => ({
- name: "SyntaxHighlighting",
- htmlPlugins() {
- return [[rehypePrettyCode, {
- theme: 'css-variables',
- } satisfies Partial<CodeOptions>]]
+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]]
+ },
}
-})
+}
--
Gitblit v1.10.0