using astro
Some checks are pending
/ deploy (push) Waiting to run

This commit is contained in:
Loyyd 2026-06-11 08:29:29 +02:00
parent 8e40b8599b
commit 830585e2ba
15 changed files with 5371 additions and 15 deletions

32
src/lib/static-pages.ts Normal file
View file

@ -0,0 +1,32 @@
import fs from "node:fs";
import path from "node:path";
export const repoRoot = process.cwd();
export const websiteRoot = path.join(repoRoot, "website");
export function walkHtmlFiles(dir = websiteRoot): string[] {
return fs.readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
const fullPath = path.join(dir, entry.name);
if (entry.isDirectory()) {
return walkHtmlFiles(fullPath);
}
return entry.isFile() && entry.name.endsWith(".html") ? [fullPath] : [];
});
}
export function relativeWebsitePath(filePath: string): string {
return path.relative(websiteRoot, filePath).split(path.sep).join("/");
}
export function routeFromRelativePath(relativePath: string): string {
if (relativePath === "index.html") {
return "";
}
return relativePath;
}
export function sourcePathFromRoute(route = ""): string {
const relativePath = route === "" ? "index.html" : route.endsWith(".html") ? route : `${route}/index.html`;
return path.join(websiteRoot, relativePath);
}