mirror of
https://github.com/pengzhanbo/vuepress-theme-plume.git
synced 2026-04-23 10:58:13 +08:00
feat: add config of autoFrontmatter
This commit is contained in:
parent
f746d46141
commit
0f88f5064f
@ -10,7 +10,10 @@ import type {
|
||||
import type { NotesItem } from '@vuepress-plume/vuepress-plugin-notes-data'
|
||||
import { format } from 'date-fns'
|
||||
import { customAlphabet } from 'nanoid'
|
||||
import type { PlumeThemeLocaleOptions } from '../shared/index.js'
|
||||
import type {
|
||||
PlumeThemePluginOptions,
|
||||
PlumeThemeLocaleOptions
|
||||
} from '../shared/index.js'
|
||||
|
||||
const nanoid = customAlphabet('0123456789abcdefghijklmnopqrstuvwxyz', 8)
|
||||
const require = createRequire(process.cwd())
|
||||
@ -28,6 +31,7 @@ const normalizePath = (dir: string) => {
|
||||
|
||||
export default function autoFrontmatter(
|
||||
app: App,
|
||||
options: PlumeThemePluginOptions,
|
||||
localeOption: PlumeThemeLocaleOptions
|
||||
): AutoFrontmatterOptions {
|
||||
const sourceDir = app.dir.source()
|
||||
@ -86,8 +90,9 @@ export default function autoFrontmatter(
|
||||
return dirList.length > 0 ? dirList[dirList.length - 1] : ''
|
||||
}
|
||||
return {
|
||||
include: ['**/*.md'],
|
||||
frontmatter: [
|
||||
include: options.frontmatter.include ?? ['**/*.{md,MD}'],
|
||||
exclude: options.frontmatter.exclude ?? ['.vuepress/**/*', 'node_modules'],
|
||||
frontmatter: options.frontmatter.frontmatter ?? [
|
||||
localesNotesDirs.length
|
||||
? {
|
||||
// note 首页链接
|
||||
|
||||
@ -55,7 +55,7 @@ export const setupPlugins = (
|
||||
: undefined,
|
||||
} as any,
|
||||
}),
|
||||
autoFrontmatterPlugin(autoFrontmatter(app, localeOptions)),
|
||||
autoFrontmatterPlugin(autoFrontmatter(app, options, localeOptions)),
|
||||
blogDataPlugin({
|
||||
include: localeOptions.blog?.include,
|
||||
exclude: [
|
||||
|
||||
@ -6,6 +6,7 @@ import type { CanIUsePluginOptions } from '@vuepress-plume/vuepress-plugin-caniu
|
||||
import type { CopyCodeOptions } from '@vuepress-plume/vuepress-plugin-copy-code'
|
||||
import type { CommentPluginOptions } from 'vuepress-plugin-comment2'
|
||||
import type { MarkdownEnhanceOptions } from 'vuepress-plugin-md-enhance'
|
||||
import type { AutoFrontmatterOptions } from '@vuepress-plume/vuepress-plugin-auto-frontmatter'
|
||||
|
||||
export interface PlumeThemePluginOptions {
|
||||
/**
|
||||
@ -49,4 +50,6 @@ export interface PlumeThemePluginOptions {
|
||||
seo?: false
|
||||
|
||||
baiduTongji?: false | BaiduTongjiOptions
|
||||
|
||||
frontmatter?: AutoFrontmatterOptions
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user