Skip to content

Commit 7d94460

Browse files
authored
Merge pull request #417 from TypedDevs/fix-frontmatter-docs
docs/fix: interpolate frontmatter variables during local search index generation
2 parents 45ffca2 + b8edbba commit 7d94460

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

docs/.vitepress/config.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,17 @@ export default defineConfig({
122122
}],
123123

124124
search: {
125-
provider: 'local'
125+
provider: 'local',
126+
options: {
127+
_render(src, env, md) {
128+
const html = md.render(src, env)
129+
130+
return html.replace(
131+
/{{\s*\$frontmatter\.(\w+)\s*}}/g,
132+
(_, key) => env.frontmatter[key]?.toString() || ''
133+
)
134+
}
135+
}
126136
},
127137

128138
footer: {

0 commit comments

Comments
 (0)