Skip to content

Commit

Permalink
fix: paths for generated results (#1163)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenFluin authored Sep 13, 2024
1 parent 1976686 commit 244fb3b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions generate-search-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import strip from "strip-markdown";
import { exit } from "process";

const client = algoliasearch("ECUG3H1E0M", process.env.ALGOLIA_KEY);
const CONTENT_PATH = "src/content/docs";

if (!process.env.ALGOLIA_KEY) {
console.error("ALGOLIA_KEY not set");
Expand All @@ -36,7 +37,7 @@ function walk(dir) {
) {
// remove file extension, order matters here
const url = filepath
.replace("src/pages", "")
.replace(CONTENT_PATH, "")
.replace(".astro", "/")
.replace(".mdx", "/")
.replace(".md", "/");
Expand Down Expand Up @@ -72,6 +73,11 @@ function walk(dir) {
if (filepath.indexOf(".astro" > -1)) {
content = stripTags(content);
}
// Remove callout
content = content.replace(
/import\s*{\s*Callout\s*}\s*from\s*['"][^"']*['"]\s*;?/g,
""
);

// Fix newlines
content = content.replace(/\n/g, " ");
Expand Down Expand Up @@ -112,9 +118,9 @@ function walk(dir) {
}
}

walk("src/content/docs");
walk(CONTENT_PATH);

//console.dir(sitemap, { maxArrayLength: null });
// console.dir(sitemap, { maxArrayLength: null });

try {
index
Expand Down

0 comments on commit 244fb3b

Please sign in to comment.