failed attempt at automatic index generation

This commit is contained in:
MapleLeaf
2021-12-30 11:48:14 -06:00
parent c15be04cdb
commit a4bd7736d5
9 changed files with 182 additions and 165 deletions

View File

@@ -0,0 +1,45 @@
/* eslint-disable unicorn/prefer-module */
const glob = require("fast-glob")
const { join, relative, normalize, parse } = require("path/posix")
/**
* @type {import('@remix-run/dev/config').AppConfig}
*/
module.exports = {
appDirectory: "app",
assetsBuildDirectory: "public/build",
publicPath: "/build/",
serverBuildDirectory: "build",
devServerPort: 8002,
ignoredRouteFiles: [".*"],
serverModuleFormat: "esm",
routes: async (defineRoutes) => {
const contentFolder = join(__dirname, "content")
const contentFiles = await glob("**/*.{md,mdx}", {
cwd: contentFolder,
absolute: true,
})
return defineRoutes((route) => {
route("docs", "docs.tsx", () => {
for (const filePath of contentFiles) {
const localFilePath = relative(contentFolder, filePath)
const { dir, name } = parse(localFilePath)
const routePath = join(dir, name)
route(routePath, filePath, { index: true })
}
})
})
},
mdx: async (filename) => {
const highlight = await import("rehype-prism-plus").then(
(mod) => mod.default,
)
return {
rehypePlugins: [highlight],
}
},
}