chore: reorganize docs apps (#7228)

* reorganize docs apps

* add README

* fix directory

* add condition for old docs
This commit is contained in:
Shahed Nasser authored and GitHub committed 2024-05-03 17:36:38 +03:00
1 parent 224ebb2154
commit 4fe28f5a95
6187 files changed
+601447 -598226

No files matched your search

@@ -0,0 +1,58 @@
import { MDXRemote } from "next-mdx-remote/rsc"
import path from "path"
import { promises as fs } from "fs"
import { notFound } from "next/navigation"
import {
typeListLinkFixerPlugin,
localLinksRehypePlugin,
} from "remark-rehype-plugins"
import MDXComponents from "@/components/MDXComponents"
import mdxOptions from "../../../mdx-options.mjs"
import { slugChanges } from "../../../generated/slug-changes.mjs"
import { filesMap } from "../../../generated/files-map.mjs"
type PageProps = {
params: {
slug: string[]
}
}
export default async function ReferencesPage({ params }: PageProps) {
const { slug } = params
// ensure that Vercel loads references files
path.join(process.cwd(), "references")
const monoRepoPath = path.resolve("..", "..", "..")
const pathname = `/references/${slug.join("/")}`
const fileDetails =
slugChanges.find((f) => f.newSlug === pathname) ||
filesMap.find((f) => f.pathname === pathname)
if (!fileDetails) {
return notFound()
}
const fullPath = path.join(monoRepoPath, fileDetails.filePath)
const fileContent = await fs.readFile(fullPath, "utf-8")
const pluginOptions = {
filePath: fullPath,
basePath: process.cwd(),
}
return (
<MDXRemote
source={fileContent}
components={MDXComponents}
options={{
mdxOptions: {
rehypePlugins: [
...mdxOptions.options.rehypePlugins,
[typeListLinkFixerPlugin, pluginOptions],
[localLinksRehypePlugin, pluginOptions],
],
remarkPlugins: mdxOptions.options.remarkPlugins,
},
}}
/>
)
}