mirror of
https://github.com/prdlk/leetcode.git
synced 2026-09-17 07:26:27 +00:00
feat(sync): organize solution docs by category and add sidebar labels
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
description: Sync work/ leetcode solutions into docs/solutions/ pages (gold standard format)
|
||||
---
|
||||
|
||||
Sync every leetcode solution under `work/` into a docs page under `docs/solutions/`, formatted like the gold standard `docs/solutions/344-reverse-string.mdx`. Extra focus (optional): $@
|
||||
Sync every leetcode solution under `work/` into a docs page under `docs/solutions/`, formatted like the gold standard `docs/solutions/(two-pointers)/344-reverse-string.mdx`. Extra focus (optional): $@
|
||||
|
||||
## Run the script
|
||||
|
||||
@@ -16,12 +16,13 @@ bun run sync
|
||||
|
||||
- Globs `work/**/*.{js,py}` (`<number>.<kebab-slug>.{js,py}` under `work/<Difficulty>/<Category>/`) and groups the two language variants of a problem by leetcode number.
|
||||
- Parses each file's header comment (js block comment / py docstring) into title, difficulty, statement, examples, constraints, and follow-up.
|
||||
- New problems get a full page at `docs/solutions/<leetcode-number>-<kebab-slug>.mdx`: frontmatter, `<Badge>` topic (README curriculum table, falling back to the `work/` subdirectory), `::::warning` for follow-ups/special requirements, examples, constraints, and the solution code verbatim.
|
||||
- The filename prefix is the leetcode problem number — it orders the sidebar numerically and is stripped from the URL (`344-reverse-string.mdx` → `/solutions/reverse-string`). The script renames any page whose filename drifts from `<leetcode-number>-<kebab-slug>.mdx`.
|
||||
- New problems get a full page at `docs/solutions/(<category>)/<leetcode-number>-<kebab-slug>.mdx`: frontmatter, `<Badge>` topic (README curriculum table, falling back to the `work/` subdirectory), `::::warning` for follow-ups/special requirements, examples, constraints, and the solution code verbatim.
|
||||
- `(<category>)` is the kebab-cased `work/` subdirectory (`(array)`, `(hash-table)`, `(two-pointers)`, …) and becomes the sidebar group; the leetcode-number filename prefix orders pages numerically. Both are stripped from the URL (`(two-pointers)/344-reverse-string.mdx` → `/solutions/reverse-string`). The script moves any page whose path drifts from this scheme.
|
||||
- Frontmatter `title` keeps the number (`'344. Reverse String'`); `sidebar.label` is the number-free problem name. The script backfills a missing `sidebar.label` on existing pages but never overwrites one.
|
||||
- Already-ported pages (frontmatter title starts with the leetcode number) only get their `## Solution` section regenerated — curated prose is never touched.
|
||||
- Problems solved in both languages render as a `<CodeGroup>` (Python first, then JavaScript); single-language solutions render as a plain fence.
|
||||
|
||||
The script prints the report table: work file → docs page → created / renamed / updated / skipped (already in sync).
|
||||
The script prints the report table: work file → docs page → created / moved / updated / skipped (already in sync).
|
||||
|
||||
## Review
|
||||
|
||||
|
||||
Reference in New Issue
Block a user