Add gitbook content commands: lint, format, broken-links#1231
Draft
gregberge wants to merge 6 commits into
Draft
Add gitbook content commands: lint, format, broken-links#1231gregberge wants to merge 6 commits into
gitbook content commands: lint, format, broken-links#1231gregberge wants to merge 6 commits into
Conversation
New command group in @gitbook/cli powered by @gitbook/content-engine (the platform's own parser/normalizer/serializer, bundled at build time): - gitbook content lint: reports content GitBook would remove or restructure on import, and invalid frontmatter. Style is not lint's concern. - gitbook content format [--write] [--force]: applies GitBook's canonical style; never alters content unless --force, which applies the full normalization (exactly what GitSync commits back). - gitbook content broken-links: checks internal links and anchors across markdown files, using the platform's section-id algorithm. The engine is loaded lazily so other commands keep their startup time. It is consumed via a file: dependency for now; switching to the npm package once @gitbook/content-engine is published. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The content-engine is now built as a self-contained ESM bundle (tsdown), so the CLI bundle switches to ESM output: - package.json: type module, postinstall script renamed to .cjs - build.sh: esm format, with a banner shimming require/__dirname for bundled CommonJS dependencies and the cloudflared tunnel path - cli.js bin shim: import instead of require Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
GitBook parses SUMMARY.md as navigation, not as a page; page-level lint/format do not apply. broken-links keeps checking it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
When the repository declares a .gitbook.yaml, the content commands interpret it like Git Sync does: - lint/format default to the configured content root, so files outside it (e.g. the GitHub-facing README.md) are not treated as GitBook content, and skip the configured structure.summary file instead of a hardcoded SUMMARY.md. - broken-links resolves pages and root-relative links against the configured root, and keeps checking the table of contents. Repositories without a .gitbook.yaml behave as before. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The content package was renamed in gitbook-x; update the file: dependency path and the imports in the content commands. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
New
gitbook contentcommand group (RND-11627), bringing GitBook's own content pipeline to local markdown/git workflows:The heavy lifting is
@gitbook/content(companion PR: GitbookIO/gitbook-x#23807), which embeds the platform's parser, normalization and serialization — so lint reports what will actually happen on import, format output is byte-identical to GitSync exports, and anchors are validated with the same section-id algorithm the renderer uses.Design decisions:
--writefixes), content changes are lint's job (errors with explicit messages like "This content will be removed because it is not supported by GitBook").formatnever applies content-altering changes unless--force."type": "module", esbuild--format=esmwith a small banner shimmingrequire/__dirnamefor bundled CJS deps and the cloudflared path, bin shim usesimport,postinstall.js→postinstall.cjs.dist/cli.jsat build time but loaded lazily, sogitbook dev/auth/etc. keep their startup time.--strict,format(check mode) fails when files need formatting.@gitbook/contentis consumed via afile:dependency on a localgitbook-xcheckout — CI will be red until the engine is published to npm. Draft until then.Tested
bun run build,tsc --noEmit, prettier clean.--help,whoami(conf/ora/api stack), and all threecontentcommands end-to-end (lint error → safe format preserves content →--force→ lint clean).gitbook dev/checkruntime (esbuild/miniflare externals import fine under ESM interop, but the dev-server path deserves a manual run before merging).🤖 Generated with Claude Code