failed attempt at automatic index generation
This commit is contained in:
@@ -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
|
||||
10
packages/docs/app/filesystem.ts
Normal file
10
packages/docs/app/filesystem.ts
Normal 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
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user