feat(plugin-blog-data): add page filters
This commit is contained in:
parent
06144f8704
commit
a15d067d9b
@ -31,6 +31,9 @@ export const preparedBlogData = async (
|
||||
let pages = app.pages.filter((page) => {
|
||||
return page.filePathRelative && pageFilter(page.filePathRelative)
|
||||
})
|
||||
if (options.pageFilter) {
|
||||
pages = pages.filter(options.pageFilter)
|
||||
}
|
||||
if (options.sortBy) {
|
||||
pages = pages.sort((prev, next) => {
|
||||
if (options.sortBy === 'createTime') {
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
import type { Page } from '@vuepress/core'
|
||||
|
||||
export interface BlogDataPluginOptions {
|
||||
include?: string | string[]
|
||||
exclude?: string | string[]
|
||||
sortBy?: 'createTime' | false | (<T>(prev: T, next: T) => boolean)
|
||||
excerpt?: boolean
|
||||
extendBlogData?: <T = any>(page: T) => Record<string, any>
|
||||
pageFilter?: (page: Page) => boolean
|
||||
}
|
||||
|
||||
export type BlogPostData<T extends object = object> = BlogPostDataItem<T>[]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user