Skip to content

Commit

Permalink
Attempt to include tags in search
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoli Nicolae <an@thundersquared.com>
  • Loading branch information
anatolinicolae committed Jul 5, 2024
1 parent 9c159e4 commit f2d2641
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
27 changes: 19 additions & 8 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,24 @@ export default defineConfigWithTheme<ThemeConfig>({
autoTitle: true,

search: {
provider: "algolia",
provider: "local",
options: {
indexName: "apiscpnotes",
appId: "TA7YISSZ4O",
apiKey: "64283e3b28dd9a7112d9a45ec6812751",
_render(src, env, md) {
let content = "";
const rendered = md.render(src, env);

// Excluding pages from search
if (env.frontmatter?.search === false) return "";

// Transforming content to include title and tags
if (env.frontmatter?.title)
content += md.render(`# ${env.frontmatter.title}`);

if (env.frontmatter?.tags)
content += md.render(`- ${env.frontmatter.tags.join("\n- ")}`);

return `${content}\n${rendered}`;
},
},
},

Expand All @@ -41,9 +54,7 @@ export default defineConfigWithTheme<ThemeConfig>({
buildSidebar({
rootPath: "./notes",
title: "Notes",
exclude: [
'index.md',
],
exclude: ["index.md"],
}),
],

Expand Down Expand Up @@ -73,5 +84,5 @@ export default defineConfigWithTheme<ThemeConfig>({
ignoreDeadLinks: [
// ignore all localhost links
/^https?:\/\/localhost/,
]
],
});
1 change: 1 addition & 0 deletions notes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

title: Home
hide_title: true
search: false
---

<div align="center">
Expand Down

0 comments on commit f2d2641

Please sign in to comment.