mirror of
https://github.com/pengzhanbo/vuepress-theme-plume.git
synced 2026-04-24 11:08:16 +08:00
22 lines
640 B
TypeScript
22 lines
640 B
TypeScript
import type { MarkdownEnv } from 'vuepress/markdown'
|
|
|
|
export interface CleanMarkdownEnv extends MarkdownEnv {
|
|
references?: unknown
|
|
abbreviations?: unknown
|
|
annotations?: unknown
|
|
}
|
|
|
|
const WHITE_LIST = ['base', 'filePath', 'filePathRelative', 'references', 'abbreviations', 'annotations'] as const
|
|
|
|
type WhiteListUnion = (typeof WHITE_LIST)[number]
|
|
|
|
export function cleanMarkdownEnv(env: CleanMarkdownEnv, excludes: WhiteListUnion[] = []): CleanMarkdownEnv {
|
|
const result: CleanMarkdownEnv = {}
|
|
for (const key of WHITE_LIST) {
|
|
if (excludes.includes(key))
|
|
continue
|
|
result[key] = env[key] as string
|
|
}
|
|
return result
|
|
}
|