Skip to content

feat(content): rewrite :icon-name: syntax in local dev#2759

Open
shsteimer wants to merge 1 commit into
mainfrom
content/local-icon-preview
Open

feat(content): rewrite :icon-name: syntax in local dev#2759
shsteimer wants to merge 1 commit into
mainfrom
content/local-icon-preview

Conversation

@shsteimer

@shsteimer shsteimer commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • aem up serves DA-cloned content directly from content/, which holds raw HTML in the same unprocessed form DA stores it. helix-html-pipeline rewrites :icon-name: text into <span class="icon icon-name"> server-side for all content, but helix-cli had no local equivalent, so :icon-name: showed as literal text when previewing locally.
  • Adds a serve-time transform in HelixServer.js, alongside the existing page-metadata handling, that mirrors this.
  • Reuses @adobe/helix-html-pipeline's own src/steps/rewrite-icons.js directly against a locally parsed HAST tree, rather than hand-porting the regex, so local behavior can't drift from what production actually does.

Fixes #2755. Follow-up for section-metadata blocks tracked in #2756.

Test plan

  • TDD: added failing unit tests in test/content-icons-html.test.js before implementing src/content/content-icons-html.js, then made them pass
  • TDD: added a failing integration test in test/server.test.js before wiring the transform into HelixServer.js, then made it pass
  • npm run lint
  • npm test

🤖 Generated with Claude Code

`aem up` serves DA-cloned content directly from content/, which holds
raw HTML the same way DA storage does. helix-html-pipeline rewrites
:icon-name: text into <span class="icon icon-name"> server-side, but
helix-cli had no local equivalent, so local previews showed literal
colon syntax instead of the icon.

Reuses @adobe/helix-html-pipeline's own rewrite-icons.js step directly
against a locally parsed HAST tree rather than porting the regex, to
avoid drift from the production behavior it mirrors.

Fixes #2755

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
import rehypeParse from 'rehype-parse';
import { toHtml } from 'hast-util-to-html';
// eslint-disable-next-line import/no-unresolved, import/extensions
import rewriteIcons from '@adobe/helix-html-pipeline/src/steps/rewrite-icons.js';

@shsteimer shsteimer Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flagging this deep import for review/discussion. Would it make sense to change helix-html-pipeline to provide these as exports for re-use? Note we'll need a similar thing to handle #2756

@shsteimer shsteimer requested review from kptdobe and tripodsan July 6, 2026 20:09
@shsteimer shsteimer marked this pull request as ready for review July 6, 2026 20:09
@tripodsan

tripodsan commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

I think this gets more and more complicated. next, you need metadata injection and the section metadata decoration etc... maybe it would be better to run the html2md -> html-pipeline chain instead.

however, is this really a usecase to render from a DA content checkout?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[content] Local dev (aem up) doesn't process :icon-name: syntax for DA content

2 participants