Update generate-index.mjs
This commit is contained in:
parent
ad1dc4a564
commit
1a8cea68e1
1 changed files with 5 additions and 1 deletions
|
|
@ -53,8 +53,13 @@ async function collectFiles(relBase = "", flat = []) {
|
||||||
|
|
||||||
for (const e of entries) {
|
for (const e of entries) {
|
||||||
if (e.name.startsWith(".")) continue;
|
if (e.name.startsWith(".")) continue;
|
||||||
|
|
||||||
const rel = path.posix.join(relBase, e.name);
|
const rel = path.posix.join(relBase, e.name);
|
||||||
const absPath = path.join(ROOT, rel);
|
const absPath = path.join(ROOT, rel);
|
||||||
|
|
||||||
|
// Skip the SPA root index file entirely — it's the shell, not content
|
||||||
|
if (rel.toLowerCase() === "index.html" || rel.toLowerCase() === "index.md") continue;
|
||||||
|
|
||||||
if (e.isDirectory()) {
|
if (e.isDirectory()) {
|
||||||
await collectFiles(rel, flat);
|
await collectFiles(rel, flat);
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -99,7 +104,6 @@ async function collectFiles(relBase = "", flat = []) {
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
const flat = await collectFiles();
|
const flat = await collectFiles();
|
||||||
// ONLY non-index files → dropdown
|
|
||||||
const sections = [...new Set(flat.filter(f => !f.isIndex).map(f => f.path.split("/")[0]))].sort();
|
const sections = [...new Set(flat.filter(f => !f.isIndex).map(f => f.path.split("/")[0]))].sort();
|
||||||
const allTags = [...new Set(flat.flatMap(f => f.tags))].sort();
|
const allTags = [...new Set(flat.flatMap(f => f.tags))].sort();
|
||||||
await fs.writeFile(OUT, JSON.stringify({ flat, sections, tags: allTags }, null, 2));
|
await fs.writeFile(OUT, JSON.stringify({ flat, sections, tags: allTags }, null, 2));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue