Another iterations

website
Zef Hemel 2022-07-15 11:51:54 +02:00
parent e4b942300a
commit c096067687
3 changed files with 34 additions and 2 deletions

3
.gitignore vendored
View File

@ -10,4 +10,5 @@ generated
*.test.js
*.js.map
.vscode
website
website
data.db

View File

@ -4,4 +4,6 @@ npm run clean-build
rm -rf website
mkdir -p website/fs
cp -r packages/web/dist/* website/
cp -r docs/* website/fs/
cp _redirects website/
cp -r docs/* website/fs/
node scripts/generate_fs_list.js > website/fs/index.json

View File

@ -0,0 +1,29 @@
const { resolve } = require("path");
const { readdir } = require("fs").promises;
async function getFiles(dir) {
const dirents = await readdir(dir, { withFileTypes: true });
const files = await Promise.all(
dirents.map((dirent) => {
const res = resolve(dir, dirent.name);
return dirent.isDirectory() ? getFiles(res) : res;
})
);
return Array.prototype.concat(...files);
}
const rootDir = resolve("docs");
getFiles(rootDir).then((files) => {
files = files
.map((file) => ({
name: file.substring(rootDir.length + 1).replace(/\.md$/, ""),
lastModified: 0,
perm: "ro",
}))
.filter(
(pageMeta) =>
!pageMeta.name.startsWith("_") && !pageMeta.name.startsWith(".")
);
console.log(JSON.stringify(files, null, 2));
});