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

@@ -1,8 +1,38 @@
import { readFile } from "node:fs/promises"
import remarkFrontmatter from "remark-frontmatter"
import remarkParse from "remark-parse"
import type { LoaderFunction } from "remix"
import { Link, Outlet } from "remix"
import { unified } from "unified"
import { SideNav } from "~/components/side-nav"
import { SidebarLayout } from "~/components/sidebar-layout"
import { linkClass } from "~/styles"
export const loader: LoaderFunction = async () => {
const glob = await import("fast-glob")
const contentFiles = await glob.default(["**/*.mdx", "**/*.md"], {
cwd: "content",
absolute: true,
})
const contentModules = await Promise.all(
contentFiles.map(async (filePath) => {
const content = await readFile(filePath, "utf8")
const result = await unified()
.use(remarkParse)
.use(remarkFrontmatter)
.process(content)
return { filePath, result: result.toString() }
}),
)
console.log(contentModules)
return {}
}
export default function Docs() {
return (
<SidebarLayout

View File

@@ -0,0 +1,10 @@
import { stat } from "node:fs/promises"
export async function isFile(path: string) {
try {
const result = await stat(path)
return result.isFile()
} catch {
return false
}
}

View File

@@ -1,30 +0,0 @@
---
meta:
title: Getting Started
description: Learn how to get started with Reacord.
---
# Getting Started
welcome
- install it and do the thing
- then do another thing
## here's a code block
```tsx
import React from "react"
function Counter() {
const [count, setCount] = useState(0)
return (
<>
You clicked {count} times
<Button onClick={() => setCount(count + 1)}>Click me</Button>
</>
)
}
```
yeah