fix: page title not found in search (#287)
部署文档 / build (push) Has been cancelled Details

pull/289/head
Rizumu Ayaka 2024-03-14 12:59:41 +08:00 committed by GitHub
parent 96c2a2c726
commit 88d0d2d30a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 0 deletions

View File

@ -75,6 +75,15 @@ export default defineConfig({
},
},
},
// Add title field in frontmatter to search
// You can exclude a page from search by adding search: false to the page's frontmatter.
_render(src, env, md) {
if (env.frontmatter?.search === false) return ''
let html = md.render(src, env)
if (env.frontmatter?.title)
html = md.render(`# ${env.frontmatter.title}\n`) + html
return html
},
},
},
},