docs: generate sitemaps + change search filters (#8957)

- Generate sitemaps for `book` and `resources` projects (in attempt to resolve some pages not being picked up by the crawler)
- Change the v2 search filters

> Note: will require changes to algolia's crawler + a recrawl once merged
This commit is contained in:
Shahed Nasser
2024-09-03 10:33:08 +00:00
committed by GitHub
parent 8e177538c1
commit f9b0605d67
8 changed files with 76 additions and 7 deletions
+1
View File
@@ -1,5 +1,6 @@
export * from "./generate-edited-dates.js"
export * from "./generate-sidebar.js"
export * from "./retrieve-mdx-pages.js"
export * from "./utils/find-metadata-title.js"
export * from "./utils/find-page-heading.js"
@@ -0,0 +1,42 @@
import { readdirSync } from "fs"
import path from "path"
import { getFileSlugSyncUtil } from "remark-rehype-plugins"
type Options = {
basePath: string
}
export function retrieveMdxPages({ basePath }: Options): string[] {
function retrieveMdxFilesInPath(dir: string): string[] {
const urls = []
const files = readdirSync(dir, {
withFileTypes: true,
})
for (const file of files) {
const filePath = path.join(dir, file.name)
if (file.isDirectory()) {
if (!file.name.startsWith("_")) {
urls.push(...retrieveMdxFilesInPath(filePath))
}
continue
} else if (file.name !== "page.mdx") {
continue
}
const slug = getFileSlugSyncUtil(filePath)
urls.push(
slug ||
filePath
.replace(basePath, "")
.replace(file.name, "")
.replace(/\/$/, "")
)
}
return urls
}
return retrieveMdxFilesInPath(basePath)
}
@@ -1,6 +1,6 @@
import { getSidebarItemLink, ItemsToAdd } from "build-scripts"
import { existsSync, readdirSync } from "fs"
import path from "path"
import { getSidebarItemLink, ItemsToAdd } from "../index.js"
export default async function getCoreFlowsRefSidebarChildren(): Promise<
ItemsToAdd[]