diff --git a/src/index.ts b/src/index.ts index e1dac9e..9a91549 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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);