diff --git a/src/markdown.ts b/src/markdown.ts index ba7a853..e5d0fe7 100644 --- a/src/markdown.ts +++ b/src/markdown.ts @@ -51,10 +51,10 @@ export function createMarkdown(options: ResolvedOptions) { if (options.frontmatter || options.excerpt) { markdown.use(frontmatterPlugin, { - renderExcerpt: false, + ...options.frontmatterOptions, grayMatterOptions: { excerpt: options.excerpt, - ...options.grayMatterOptions, + ...options.frontmatterOptions.grayMatterOptions, }, }) } diff --git a/src/options.ts b/src/options.ts index 160f0c8..60f6b53 100644 --- a/src/options.ts +++ b/src/options.ts @@ -8,22 +8,22 @@ export function resolveOptions(userOptions: Options): ResolvedOptions { headEnabled: false, headField: '', frontmatter: true, - include: null, - exclude: null, excerpt: false, exposeFrontmatter: true, exposeExcerpt: false, escapeCodeTagInterpolation: true, customSfcBlocks: ['route', 'i18n', 'style'], componentOptions: {}, + frontmatterOptions: {}, markdownItOptions: {}, markdownItUses: [], markdownItSetup: () => {}, - grayMatterOptions: {}, wrapperComponent: null, transforms: {}, vueVersion: userOptions.vueVersion || getVueVersion(), wrapperClasses: 'markdown-body', + include: null, + exclude: null, } const options = userOptions.frontmatterPreprocess ? { ...defaultOptions, ...userOptions } diff --git a/src/types.ts b/src/types.ts index 0bf7db7..4a42a42 100644 --- a/src/types.ts +++ b/src/types.ts @@ -91,6 +91,11 @@ export interface Options { */ componentOptions?: ComponentPluginOptions + /** + * Options passed to [@mdit-vue/plugin-frontmatter](https://github.com/mdit-vue/mdit-vue/tree/main/packages/plugin-frontmatter) + */ + frontmatterOptions?: FrontmatterPluginOptions + /** * Custom function to provide defaults to the frontmatter and * move certain attributes into the "meta" category. @@ -149,11 +154,6 @@ export interface Options { */ markdownItSetup?: (MarkdownIt: MarkdownIt) => void - /** - * Options passed to [gray-matter](https://github.com/jonschlinkert/gray-matter#options) - */ - grayMatterOptions?: FrontmatterPluginOptions['grayMatterOptions'] - /** * Class names for wrapper div * diff --git a/test/__snapshots__/excerpt.test.ts.snap b/test/__snapshots__/excerpt.test.ts.snap index 92960ce..68bf89d 100644 --- a/test/__snapshots__/excerpt.test.ts.snap +++ b/test/__snapshots__/excerpt.test.ts.snap @@ -1,7 +1,7 @@ // Vitest Snapshot v1 -exports[`excerpt > basic-excerpt 1`] = ` -"