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