Skip to content

Commit 12d54e0

Browse files
committed
more fixes
1 parent 693a0b1 commit 12d54e0

3 files changed

Lines changed: 26 additions & 16 deletions

File tree

src/components/cookbook/CookbookIndex/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default function CookbookIndex({ sections = [] }) {
3939

4040
<p className={styles.footNote}>
4141
{total} recipes across {sections.length} sections: 61 standalone projects
42-
reconstructed and built in CI, plus 8 focused reference pages. Card badges
42+
reconstructed and built in CI, plus 11 focused reference pages. Card badges
4343
state which artifact the page contains.
4444
</p>
4545
</div>

testing/cookbook-ts/legacy-cookbook-redirects.test.mjs

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import assert from "node:assert/strict";
2-
import fs from "node:fs";
2+
import { createRequire } from "node:module";
33
import test from "node:test";
44
import {
55
COOKBOOK_PATH,
@@ -8,12 +8,29 @@ import {
88
legacyCookbookRedirects,
99
} from "../../src/components/cookbook/LegacyCookbookRedirect/legacyCookbookRedirects.mjs";
1010

11-
const manifest = JSON.parse(
12-
fs.readFileSync(
13-
new URL("../../src/data/cookbook-manifest.json", import.meta.url),
14-
"utf8",
15-
),
16-
);
11+
const require = createRequire(import.meta.url);
12+
const sidebars = require("../../sidebars.js");
13+
const recipePaths = new Set();
14+
const sectionPaths = new Set();
15+
16+
function collectCookbookPaths(node) {
17+
if (Array.isArray(node)) {
18+
for (const child of node) collectCookbookPaths(child);
19+
} else if (typeof node === "string") {
20+
const route = node.startsWith("/") ? node : `/${node}`;
21+
const match = route.match(
22+
new RegExp(`^${COOKBOOK_PATH}/([^/]+)/[^/]+$`),
23+
);
24+
if (match) {
25+
recipePaths.add(route);
26+
sectionPaths.add(`${COOKBOOK_PATH}#${match[1]}`);
27+
}
28+
} else if (node && typeof node === "object") {
29+
for (const value of Object.values(node)) collectCookbookPaths(value);
30+
}
31+
}
32+
33+
collectCookbookPaths(sidebars.docs);
1734

1835
test("maps every legacy cookbook anchor exactly once", () => {
1936
const groupedAnchors = legacyCookbookRedirectGroups.flatMap(
@@ -26,13 +43,6 @@ test("maps every legacy cookbook anchor exactly once", () => {
2643
});
2744

2845
test("points every legacy anchor at an existing recipe or cookbook section", () => {
29-
const recipePaths = new Set(
30-
manifest.flatMap(({ recipes }) => recipes.map(({ href }) => href)),
31-
);
32-
const sectionPaths = new Set(
33-
manifest.map(({ id }) => `${COOKBOOK_PATH}#${id}`),
34-
);
35-
3646
for (const [anchor, target] of Object.entries(legacyCookbookRedirects)) {
3747
assert.ok(
3848
target === COOKBOOK_PATH ||

testing/cookbook-ts/verify-projects.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import path from 'node:path';
77
import { fileURLToPath } from 'node:url';
88

99
const EXPECTED_PROJECTS = 61;
10-
const EXPECTED_REFERENCES = 8;
10+
const EXPECTED_REFERENCES = 11;
1111
const REQUIRED_NODE_RANGE = '>=20.19.0';
1212
const scriptDirectory = path.dirname(fileURLToPath(import.meta.url));
1313
const extractedRoot = path.join(scriptDirectory, 'project', 'src', 'recipes');

0 commit comments

Comments
 (0)