|
|
@@ -1,6 +1,6 @@ |
|
|
|
--- |
|
|
|
import { readdir, readFile } from 'node:fs/promises'; |
|
|
|
const { default: Default } = await import('../layouts/Default.astro'); |
|
|
|
import Default from '../content/layouts/Default.astro'; |
|
|
|
|
|
|
|
type Frontmatter = Record<string, unknown>; |
|
|
|
|
|
|
@@ -9,7 +9,7 @@ interface PageProps { |
|
|
|
} |
|
|
|
|
|
|
|
const title = 'Table of Contents' |
|
|
|
const allPages = await readdir('src/pages'); |
|
|
|
const allPages = await readdir('src/content/chapters'); |
|
|
|
const pages = allPages.filter((p) => ( |
|
|
|
!p.startsWith('index.') |
|
|
|
&& !p.endsWith('.astro') |
|
|
@@ -18,7 +18,7 @@ const pages = allPages.filter((p) => ( |
|
|
|
|
|
|
|
const pagesContentImported = await Promise.all( |
|
|
|
pages.map(async (p) => { |
|
|
|
const fileBuffer = await readFile(`src/pages/${p}`); |
|
|
|
const fileBuffer = await readFile(`src/content/chapters/${p}`); |
|
|
|
const file = fileBuffer.toString('utf-8'); |
|
|
|
|
|
|
|
const [, frontmatterRaw] = file.split('---'); |
|
|
@@ -39,7 +39,7 @@ const pagesContentImported = await Promise.all( |
|
|
|
<ol> |
|
|
|
{pagesContentImported.map(([p, f]) => ( |
|
|
|
<li> |
|
|
|
<a href={p.replace('.mdx', '')}> |
|
|
|
<a href={`chapters/${p.replace('.mdx', '')}`}> |
|
|
|
{f.frontmatter.title} |
|
|
|
</a> |
|
|
|
</li> |
|
|
|