refactor(cli): clarify topic folder handling and remove unused groupFolder helper

This commit is contained in:
Prad Nukala committed 2026-09-21 17:37:19 -04:00
1 parent 2e5d991d47
commit 891a1f0c5a
1 file changed
+10 -8
+10 -8
View File
@@ -12,11 +12,17 @@
* render as a plain fence.
*
* Two classifications, two homes. The sidebar group is the campaign TOPIC
* from the README table (`(tree-dfs)/`, ordered by topic number via a
* from the README table (`tree-dfs/`, ordered by topic number via a
* script-owned `meta.ts`); the page badge is the data-structure CATEGORY the
* file sits under in `work/1/<Difficulty>/<Category>/`. A problem outside the
* plan (warm-ups) has no topic, so it groups under its category instead.
*
* Topic folders are real route segments (`/tree-dfs/invert-binary-tree`), not
* `(group)` folders, so a hand-written `index.mdx` in one is the topic's
* landing page at `/tree-dfs` and Blume links the sidebar group row to it.
* Sync never writes or moves an `index.mdx`, and never removes a folder that
* still holds one.
*
* Only the first-solve bucket is read: work/3 and work/7 hold blind re-solves
* of problems whose page already exists (see work.ts), and a fresh scaffold
* there would otherwise wipe the page's `## Solution`.
@@ -190,11 +196,6 @@ async function readmeTopics(): Promise<Map<number, Topic>> {
return map;
}
/** `(group)` folder name: route-transparent in Blume, so only the sidebar sees it. */
function groupFolder(topic: Topic): string {
return `(${topic.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "")})`;
}
/** Blume folder meta: exact topic label (the folder slug loses `/` and case) and curriculum order. */
function groupMeta(topic: Topic): string {
const order = topic.order === undefined ? "" : `, order: ${topic.order}`;
@@ -422,11 +423,12 @@ const vacated = new Set<string>(); // folders a page moved out of; removed below
for (const sol of ordered) {
const langs = Object.keys(sol.code).sort().join("+");
const workRef = `${sol.num}.${sol.slug} (${langs})`;
// (topic) group folder + leetcode-number prefix: numeric sidebar order, both stripped from the URL.
// <topic>/ folder (a real route segment, so its index.mdx is the topic landing
// page) + leetcode-number prefix: numeric sidebar order, prefix stripped from the URL.
// An unplanned problem's category may share a folder with a numbered topic
// (`Hash Table` warm-ups under topic 1); the numbered one owns the meta.
const topic = topics.get(sol.num) ?? { name: sol.category };
const group = groupFolder(topic);
const group = topic.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
if (groups.get(group)?.order === undefined) groups.set(group, topic);
const name = `${group}/${sol.num}-${sol.slug}.mdx`;
const existing = pages.get(sol.num);