feat(frontend): serve the documentation from the frontend - #465
Open
marcalexiei wants to merge 1 commit into
Open
feat(frontend): serve the documentation from the frontend#465marcalexiei wants to merge 1 commit into
marcalexiei wants to merge 1 commit into
Conversation
|
@marcalexiei is attempting to deploy a commit to the martin-mfg's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Implements option A of #461.
(Closes #461)
Serving the docs from the frontend at
/frontend/docsships them with the API in one commit, so samples resolve against the deployment serving them.Documentation PRs can be merged as soon as they are approved.
Nothing they add reaches users until the same release promotion that ships the code they describe, so there is no longer a reason to hold an approved PR back until just before a release, and nothing to re-check afterwards.
Note
Please look at the documentation layout and the general approach before the code, and say whether that is the direction we want to take. The code is easy to adjust afterwards.
I asked Claude Opus 5 to help build the docs site, so most of
apps/frontend/src/docsand its styling come from there, with follow up adjustments by me.Try it
Then open http://localhost:5173/frontend/docs.
The wizard links to it from the header, and from steps 3 and 4.
Summary
Changes
frontend/docsroute in the existing app, wizard and docs lazy-loaded so neither pays for the other.vite-plugin-markdown, withmarkdown-it-github-alertsfor> [!NOTE]blockquotes.Nothing markdown-related reaches the browser.
markdown-it-anchor, at build time.transformDocHtmlresolves what the compiler doesn't: repo-relative links to?page=queries, hosted card URLs to site-relative.docs/index.mdas a docs-specific overview, withREADME.mdtrimmed to a landing page linking to it.apps/frontend/src/split intodocs/,wizard/andshared/;AppTrendsrenamed toWizard.master,through a
docsUrlhelper typed from the page list, so a renamed page breaks the build.LinkExternalreplaces the hand-repeatedtarget/relpairs and marks new-tab links with an icon (which can be disabled via prop).vercel-preparation.shcopies the entry point tostatic/frontend/docs/, keeping the output filesystem based.Why some rewriting is at build time and some at runtime
Any rewriting is needed at all because the sources are read in two places:
on github.com they have to work as they are, so they keep absolute card URLs and repository-relative
.mdlinks,while the site needs those pointing at the serving deployment and at
?page=routes.Heading ids and their permalinks are markdown, so
markdown-it-anchorhandles them during the build.The rest stays in
transformDocHtml, because two cases markdown-it cannot see:<picture><source srcset="…">blocks, which markdown-it emits as opaquehtml_blocktokens, so renderer rules never touch them.frontend-screenshot.pnghas to become a hashed Vite asset URL, which only the bundler knows.Only 24 of the 251 hosted URLs are raw HTML; the rest is markdown syntax.
So if the site ever becomes the only place the docs are read, those blocks could go site-relative, the rest could move into markdown-it rules, and
transformDocHtmlcould go away.