Made excluded variable that excludes pages from search (#3999)

This commit is contained in:
Royiex 2025-08-31 09:20:26 +02:00 committed by GitHub
parent 7b50331af4
commit 0dd5ff2ec0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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') {
consola.info('FMHY_BUILD_NSFW is set to false, disabling NSFW content')
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'] = {
options: {
_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
// I do this as env.frontmatter is not available until I call `md.render`
if (contents.includes('Beginners Guide'))