agregar indice al reporte

This commit is contained in:
Cat /dev/Nulo 2023-03-31 20:52:49 -03:00
parent 30b41a6811
commit 679cc3e3f2

View file

@ -12,6 +12,7 @@ import {
h2,
ol,
basicElement,
a,
} from "@nulo/html.js";
const { argv } = process;
@ -156,7 +157,9 @@ await recurseDirectory(reports, dirPath);
const totalThings = [...reports.entries()].flatMap(([name, r]) =>
r.things.map((t) => ({ ...t, fileName: name }))
);
const kinds = new Set(totalThings.map((t) => t.type));
const kinds = [...new Set(totalThings.map((t) => t.type))].sort((a, b) =>
["link-http", "link-no-href"].includes(b) ? -1 : 0
);
console.log(
`Finished with ${Object.keys(reports).length} files read, ${
totalThings.length
@ -202,17 +205,16 @@ const html = render(
`${linkHttp} links to HTTP sites, which is not a real concern unless it's a key part of the site's navigation.`
)
),
...[...kinds]
.sort((a, b) => (b === "link-http" ? -1 : 0))
.flatMap((kind) => [
h2(kind),
ol(
...totalThings
.filter((t) => t.type === kind)
.map((t) =>
li(code(relative(dirPath, t.fileName)), ": ", code(t.description))
)
),
])
ul(...kinds.map((k) => li(a({ href: "#" + k }, k)))),
...kinds.flatMap((kind) => [
h2({ id: kind }, kind),
ol(
...totalThings
.filter((t) => t.type === kind)
.map((t) =>
li(code(relative(dirPath, t.fileName)), ": ", code(t.description))
)
),
])
);
await writeFile(reportOutput, html);