parent
8e40b8599b
commit
830585e2ba
15 changed files with 5371 additions and 15 deletions
23
src/pages/[...route].ts
Normal file
23
src/pages/[...route].ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import fs from "node:fs/promises";
|
||||
import { relativeWebsitePath, routeFromRelativePath, sourcePathFromRoute, walkHtmlFiles } from "../lib/static-pages";
|
||||
|
||||
export function getStaticPaths() {
|
||||
return walkHtmlFiles()
|
||||
.map(relativeWebsitePath)
|
||||
.filter((relativePath) => relativePath !== "index.html")
|
||||
.map((relativePath) => ({
|
||||
params: {
|
||||
route: routeFromRelativePath(relativePath),
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
export async function GET({ params }: { params: { route?: string } }) {
|
||||
const html = await fs.readFile(sourcePathFromRoute(params.route), "utf8");
|
||||
|
||||
return new Response(html, {
|
||||
headers: {
|
||||
"content-type": "text/html; charset=utf-8",
|
||||
},
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue