mirror of
				https://github.com/zopiya/x-eden-quartz.git
				synced 2025-11-04 06:46:48 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			32 lines
		
	
	
		
			711 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			711 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
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]]
 | 
						|
    },
 | 
						|
  }
 | 
						|
}
 |