mirror of
https://github.com/fmhy/edit.git
synced 2025-10-13 08:11:07 +11:00
Made excluded variable that excludes pages from search
This commit is contained in:
parent
bbacad46b3
commit
9df4fc27ce
1 changed files with 21 additions and 0 deletions
|
@ -31,6 +31,15 @@ export const meta = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const excluded = [
|
||||||
|
'readme.md',
|
||||||
|
'single-page',
|
||||||
|
'feedback.md',
|
||||||
|
'index.md',
|
||||||
|
'sandbox.md',
|
||||||
|
'startpage.md'
|
||||||
|
]
|
||||||
|
|
||||||
if (process.env.FMHY_BUILD_NSFW === 'false') {
|
if (process.env.FMHY_BUILD_NSFW === 'false') {
|
||||||
consola.info('FMHY_BUILD_NSFW is set to false, disabling NSFW content')
|
consola.info('FMHY_BUILD_NSFW is set to false, disabling NSFW content')
|
||||||
meta.build.nsfw = false
|
meta.build.nsfw = false
|
||||||
|
@ -55,6 +64,18 @@ export const feedback = `<a href="/feedback" class="feedback-footer">Made with
|
||||||
export const search: DefaultTheme.Config['search'] = {
|
export const search: DefaultTheme.Config['search'] = {
|
||||||
options: {
|
options: {
|
||||||
_render(src, env, md) {
|
_render(src, env, md) {
|
||||||
|
// Check if current file should be excluded from search
|
||||||
|
const relativePath = env.relativePath || env.path || ''
|
||||||
|
const shouldExclude = excluded.some(excludedFile =>
|
||||||
|
relativePath.includes(excludedFile) ||
|
||||||
|
relativePath.endsWith(excludedFile)
|
||||||
|
)
|
||||||
|
|
||||||
|
// Return empty content for excluded files so they don't appear in search
|
||||||
|
if (shouldExclude) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
let contents = src
|
let contents = src
|
||||||
// I do this as env.frontmatter is not available until I call `md.render`
|
// I do this as env.frontmatter is not available until I call `md.render`
|
||||||
if (contents.includes('Beginners Guide'))
|
if (contents.includes('Beginners Guide'))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue