mirror of https://github.com/YunYouJun/valaxy
feat: allow custom fuse list glob pattern
This commit is contained in:
parent
58e30a3a33
commit
d3c4657142
|
@ -33,6 +33,10 @@ export default defineSiteConfig({
|
|||
type: 'fuse',
|
||||
},
|
||||
fuse: {
|
||||
/**
|
||||
* 设置搜索的文件路径
|
||||
*/
|
||||
// pattern: 'pages/**/*.md',
|
||||
options: {
|
||||
keys: ['title', 'tags', 'categories', 'excerpt', 'content'],
|
||||
/**
|
||||
|
|
|
@ -21,7 +21,8 @@ import { setEnvProd } from '../utils/env'
|
|||
export async function generateFuseList(options: ResolvedValaxyOptions) {
|
||||
consola.start(`Generate List for Fuse Search by (${colors.cyan('fuse.js')}) ...`)
|
||||
// generate
|
||||
const files = await fg(`${options.userRoot}/pages/**/*.md`)
|
||||
const pattern = options.config.siteConfig.fuse.pattern || path.join(options.userRoot, 'pages/**/*.md')
|
||||
const files = await fg(pattern)
|
||||
|
||||
const posts: FuseListItem[] = []
|
||||
for await (const i of files) {
|
||||
|
|
|
@ -180,6 +180,14 @@ export interface SiteConfig {
|
|||
* @description 搜索结果列表数据所在路径
|
||||
*/
|
||||
dataPath: string
|
||||
/**
|
||||
* fast-glob pattern to match Fuse List Data
|
||||
* @default `pages\/**\/*.md`
|
||||
* ```ts
|
||||
* await fg(`${userRoot}/pages/posts/**\/*.md`)
|
||||
* ```
|
||||
*/
|
||||
pattern?: string
|
||||
/**
|
||||
* @see https://fusejs.io/api/options.html
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue