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:
1 parent
8e177538c1
commit
f9b0605d67
8 files changed
+76
-7
No files matched your search
@@ -0,0 +1,13 @@
|
|||||||
|
import { retrieveMdxPages } from "build-scripts"
|
||||||
|
import type { MetadataRoute } from "next"
|
||||||
|
import path from "path"
|
||||||
|
import { config } from "../config"
|
||||||
|
import { basePathUrl } from "../utils/base-path-url"
|
||||||
|
|
||||||
|
export default function sitemap(): MetadataRoute.Sitemap {
|
||||||
|
return retrieveMdxPages({
|
||||||
|
basePath: path.resolve("app"),
|
||||||
|
}).map((filePath) => ({
|
||||||
|
url: `${config.baseUrl}${basePathUrl(filePath)}`,
|
||||||
|
}))
|
||||||
|
}
|
||||||
@@ -74,7 +74,7 @@ const SearchProvider = ({ children }: SearchProviderProps) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
initialDefaultFilters={["book"]}
|
initialDefaultFilters={["guides"]}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</UiSearchProvider>
|
</UiSearchProvider>
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { retrieveMdxPages } from "build-scripts"
|
||||||
|
import type { MetadataRoute } from "next"
|
||||||
|
import path from "path"
|
||||||
|
import { config } from "../config"
|
||||||
|
import { basePathUrl } from "../utils/base-path-url"
|
||||||
|
|
||||||
|
export default function sitemap(): MetadataRoute.Sitemap {
|
||||||
|
return retrieveMdxPages({
|
||||||
|
basePath: path.resolve("app"),
|
||||||
|
}).map((filePath) => ({
|
||||||
|
url: `${config.baseUrl}${basePathUrl(filePath)}`,
|
||||||
|
}))
|
||||||
|
}
|
||||||
@@ -63,7 +63,7 @@ const SearchProvider = ({ children }: SearchProviderProps) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
initialDefaultFilters={["resources"]}
|
initialDefaultFilters={["guides"]}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</UiSearchProvider>
|
</UiSearchProvider>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
export * from "./generate-edited-dates.js"
|
export * from "./generate-edited-dates.js"
|
||||||
export * from "./generate-sidebar.js"
|
export * from "./generate-sidebar.js"
|
||||||
|
export * from "./retrieve-mdx-pages.js"
|
||||||
|
|
||||||
export * from "./utils/find-metadata-title.js"
|
export * from "./utils/find-metadata-title.js"
|
||||||
export * from "./utils/find-page-heading.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 { existsSync, readdirSync } from "fs"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
|
import { getSidebarItemLink, ItemsToAdd } from "../index.js"
|
||||||
|
|
||||||
export default async function getCoreFlowsRefSidebarChildren(): Promise<
|
export default async function getCoreFlowsRefSidebarChildren(): Promise<
|
||||||
ItemsToAdd[]
|
ItemsToAdd[]
|
||||||
|
|||||||
@@ -184,12 +184,12 @@ export const mobileSidebarItemsV2: SidebarItem[] = [
|
|||||||
|
|
||||||
export const searchFiltersV2: OptionType[] = [
|
export const searchFiltersV2: OptionType[] = [
|
||||||
{
|
{
|
||||||
value: "book",
|
value: "guides",
|
||||||
label: "Docs v2",
|
label: "Guides",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "resources",
|
value: "references-v2",
|
||||||
label: "Learning Resources",
|
label: "References",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "admin-v2",
|
value: "admin-v2",
|
||||||
|
|||||||
Reference in new issue
Block a user