Skip to content

Commit 3e244d7

Browse files
committed
Exclude translated and versions from search
1 parent 6a29758 commit 3e244d7

File tree

2 files changed

+8
-29
lines changed

2 files changed

+8
-29
lines changed

.vitepress/config.mts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ export default defineVersionedConfig(
4949

5050
themeConfig: {
5151
search: {
52+
options: {
53+
_render(src, env, md) {
54+
if (env.frontmatter?.search === false) return "";
55+
if (env.relativePath.startsWith("translated/")) return "";
56+
if (env.relativePath.startsWith("versions/")) return "";
57+
return md.render(src, env);
58+
},
59+
},
5260
provider: "local",
5361
},
5462
},

.vitepress/update.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -138,35 +138,6 @@ import players from "./sidebars/players";
138138

139139
console.log("Updated internal links.");
140140

141-
console.log("Adding search:false frontmatter to all markdown files...");
142-
143-
for (const file of versionedMarkdownFiles) {
144-
const data = fs.readFileSync(file, "utf-8");
145-
// Check if the file has frontmatter
146-
if (data.startsWith("---")) {
147-
// Find the end of the frontmatter
148-
const endOfFrontmatter = data.indexOf("---", 3);
149-
150-
// Extract the frontmatter
151-
let frontmatter = data.slice(0, endOfFrontmatter);
152-
153-
// Add 'search: false' to the frontmatter
154-
if (!frontmatter.includes("search:")) {
155-
frontmatter += EOL + "search: false" + EOL;
156-
157-
// Replace the old frontmatter with the updated one
158-
const updatedData = frontmatter + data.slice(endOfFrontmatter);
159-
160-
// Write the updated data back to the file
161-
fs.writeFile(file, updatedData, function (err) {
162-
if (err) {
163-
console.log(err);
164-
}
165-
});
166-
}
167-
}
168-
}
169-
170141
console.log("Adding warning box to index.md...");
171142
fs.writeFileSync(
172143
`./versions/${oldVersion}/index.md`,

0 commit comments

Comments
 (0)