perf: render static prose tags as native elements with baked-in classes - #34
Open
atinux wants to merge 1 commit into
Open
perf: render static prose tags as native elements with baked-in classes#34atinux wants to merge 1 commit into
atinux wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
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.
Summary
Long docs pages mount a Nuxt UI
Prose*component instance for every paragraph, list item, table cell, and heading. This PR renders those static tags as plain HTML elements instead, with their Tailwind classes baked into the parsed tree, cutting per-node component instances from SSR, hydration, and client-side navigation.How it works
elementscomark plugin (server/utils/comark-elements.ts): runs last in the parse pipeline and rewritesp,em,strong,hr,ul,ol,li,blockquote, inlinecode, the table family, andh1-h4into final HTML with classes merged from the Nuxt UI prose theme +appConfig.ui.prose.*overrides, using the sametv({ extend: theme, ...override })call the components make. It replicates component markup: table scroll-wrapperdiv, heading anchor links (permdc.headings.anchorLinks) with the hash icon as a CSS mask,codecolor variants, cell alignment.presubtrees are untouched (rangi owns them).proseElementsmap (app/utils/prose-elements.ts): passed to<MarkdownDocument :components>, mapping each tag to its own name so the renderer emitsh('p')instead of resolving the globalProseP. Heading anchors use aprose-anchortag mapped to'a'so they do not resolve toProseA.ProseImgstays a component (zoom dialog) but is now lazily hydrated withhydrateOnVisible(): its chunk (the largest prose chunk, 5.2 KB) only downloads once an image scrolls into view.a,pre, callouts, tabs, code groups, etc. Children of native elements render normally, so in-content links keep SPA navigation.Wiring
server/utils/content.ts;CONTENT_PARSER_VERSIONbumped tov3(cached trees change shape).MarkdownDocumentusages.server/added as a Tailwind source inmodules/css.tsso the baked class literals stay covered even if they drift from the Nuxt UI theme.tailwind-variantsadded as a direct dependency (the plugin cannot use@nuxt/ui/utils/tv: it imports#build/app.config, which is forbidden in nitro).Impact
ProseImgdeferred until visible.tv()calls, anduseAppConfigproxies for ~19 tags during SSR, hydration, and every client-side navigation.Trade-offs
appConfig.ui.prose.*overrides are applied at parse time and frozen into the cached tree (still respected, verified in tests, but runtimeUThemecontext overrides no longer affect these tags).@nuxt/ui(noted in the plugin docblock).Verification
test/comark-elements.test.ts): class baking, app.config merging, author-class preservation,preskip, table wrapper, heading anchors, alignment. Full suite: 164 passed.nuxt typecheckclean, eslint clean (only pre-existing warnings).ProseAlink styling, and image zoom attributes are identical.🤖 Opened by an AI coding agent (OpenCode) on behalf of @atinux, who reviewed the changes.