testPagesFollowTheIndex

tcmts.site.testPagesFollowTheIndex · #6lxlaiyf · term

The site's pages are the index's, in its order and sections, and every one is a page the site has.

import { pageList, resolvePath, SOURCES } from "#codebase/tcmts/site";
import assert from "node:assert/strict";

export const testPagesFollowTheIndex = () => {
  const pages = pageList(SOURCES["docs/README.md"]!);
  assert.deepEqual(pages[0], { src: "docs/README.md", file: "index.html", label: "index", n: 0 });
  assert.ok(pages.length > 30);
  assert.ok(pages.some((p) => p.src === "examples/README.md" && p.file === "examples.html"));
  for (const p of pages) assert.ok(p.src in SOURCES, `${p.src} is one of the site's pages`);
  assert.equal(resolvePath("docs", "../examples/README.md"), "examples/README.md");
  assert.equal(resolvePath("docs", "./apps.md"), "docs/apps.md");
}

uses