Skip to content

Perf/improve post write extras - #7063

Open
fabianrbz wants to merge 20 commits into
mainfrom
perf/improve-post-write-extras
Open

Perf/improve post write extras#7063
fabianrbz wants to merge 20 commits into
mainfrom
perf/improve-post-write-extras

Conversation

@fabianrbz

Copy link
Copy Markdown
Contributor

Description

Perf tweaks and some fixes, it should reduce the build time by ~50%

Fixes #issue

Preview Links

Checklist

  • Tested how-to docs. If not, note why here.
  • All pages contain metadata.
  • Any new docs link to existing docs.
  • All autogenerated instructions render correctly (API, decK, Konnect, Kong Manager).
  • Style guide (capitalized gateway entities, placeholder URLs) implemented correctly.
  • Every page has a description entry in frontmatter.
  • Add new pages to the product documentation index (if applicable).

@netlify

netlify Bot commented Sep 1, 2026

Copy link
Copy Markdown

Deploy Preview for kongdeveloper ready!

Name Link
🔨 Latest commit 7470603
🔍 Latest deploy log https://app.netlify.com/projects/kongdeveloper/deploys/6a97db9b2bcbb50008c0e5ea
😎 Deploy Preview https://deploy-preview-7063--kongdeveloper.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@fabianrbz
fabianrbz marked this pull request as ready for review September 1, 2026 12:02
@fabianrbz
fabianrbz requested a review from a team as a code owner September 1, 2026 12:02
- 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
&quot; instead of breaking the tag.
@fabianrbz
fabianrbz force-pushed the perf/improve-post-write-extras branch from b887dcc to 7470603 Compare September 2, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant