Perf/improve post write extras - #7063
Open
fabianrbz wants to merge 20 commits into
Open
Conversation
✅ Deploy Preview for kongdeveloper ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
- Switched from Nokogiri → Nokolexbor (faster HTML parser) - Split processing into two methods: - process runs at :post_convert (on page content, before layout merge) — handles most pages fast - process_output runs at :post_render (full output) — fallback for generator-produced and landing pages - Removed rewrite_external_links regex approach (replaced by Kramdown monkeypatch)
Monkeypatches Kramdown::Converter::Html#convert_a to add target="_blank" rel="noopener nofollow noreferrer" to all https?:// links at AST conversion time. Covers all Markdown-sourced content without a post-render regex pass
- Liquid include that generates an anchor-wrapped heading (<hN id="..."><a ...>text<span>icon</span></a></hN>) - Supports tag, id, text, content (rich HTML override), and class params - Used by all templates that produce headings outside of Markdown content
Hardcoded external links in layout HTML templates that are never processed by Kramdown — added target="_blank" rel="noopener nofollow noreferrer" directly
14 template files that had raw <hN id="..."> headings that were being skipped by the hook
…nd ID ordering Move heading anchor injection from :post_render to :post_convert so it operates on page.content before layout, avoiding a full-page Nokolexbor parse on every rendered page. Replace css() with an XPath traversal so compound heading IDs (gateway/changelog, operator/reference/custom-resources) are assigned in document order rather than grouped by tag — fixing wrong h2 prefixes on h3 entries in those pages. Skip the :post_render pass entirely for pages where :post_convert already injected anchors, cutting ~20s from full-site build time.
… fragments Nokolexbor::DocumentFragment#xpath silently returns no results when the fragment has multiple top-level sibling nodes — which any plain markdown body has (headings and paragraphs as flat siblings, no single wrapping element). This made collect_heading_ops find zero headings on most pages, deferring every heading rewrite to the expensive :post_render pass and, on pages where the TOC renders before that pass runs, leaving the TOC pointing at stale/uncorrected heading ids. Wrap parsed content in a synthetic <div> root (parse_fragment) before running xpath. This keeps the correct document-order traversal needed for compound heading IDs while fixing xpath to actually find headings on ordinary flat-sibling content. Also drops the now-unused HEADING_SELECTOR css-selector constant.
correctly in the frontmatter of the md version
Unescaped quote characters in page title/description were terminating the content="..." attribute early, garbling og:title, og:description, and algolia:title/description into bogus HTML attributes on affected pages. Pipe both values through `escape` after `liquify` in default.html and search_tags.html so embedded quotes render as " instead of breaking the tag.
fabianrbz
force-pushed
the
perf/improve-post-write-extras
branch
from
September 2, 2026 08:17
b887dcc to
7470603
Compare
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.
Description
Perf tweaks and some fixes, it should reduce the build time by ~50%
Fixes #issue
Preview Links
Checklist
descriptionentry in frontmatter.