Skip to content

feat(blog): switch blog content rendering from Markdown to HTML#1

Merged
JordanChoo merged 2 commits into
mainfrom
feat/blog-content-md-to-html
Jun 14, 2026
Merged

feat(blog): switch blog content rendering from Markdown to HTML#1
JordanChoo merged 2 commits into
mainfrom
feat/blog-content-md-to-html

Conversation

@JordanChoo

Copy link
Copy Markdown
Owner

Summary

  • Switch blog article rendering from renderMarkdown to renderHtml so interactive HTML elements (iframes, styled content, etc.) authored in the Directus WYSIWYG editor render correctly instead of being treated as raw Markdown.
  • Add rehype-parse dependency and a new renderHtml pipeline that parses HTML fragments directly via rehype-parse with a permissive blog-specific sanitization schema (blogHtmlSanitizationSchema) that allows iframes, mark, aside, style attributes, and additional img attributes.
  • Location content (normalize-locations.ts) is unchanged — FAQ answers and long descriptions continue to use Markdown rendering.

Changed files

  • package.json / pnpm-lock.yaml — added rehype-parse
  • src/lib/directus/markdown.ts — added rehypeParse import, blogHtmlSanitizationSchema, htmlProcessor, and exported renderHtml function
  • src/lib/directus/normalize.ts — switched blog article rendering from renderMarkdown to renderHtml
  • src/lib/directus/types.ts — added // HTML comment to DirectusBlogArticle.content
  • src/lib/content/types.ts — added // HTML (CMS) or Markdown (local) comment to BlogPost.content

Test plan

  • Verify pnpm build succeeds with no new type errors
  • Create a blog article in Directus with WYSIWYG HTML content (including an iframe embed and styled elements) and confirm it renders correctly on the blog post page
  • Verify existing blog articles with simple HTML content still render correctly
  • Confirm location pages (FAQ answers, long descriptions) still render via Markdown and are unaffected
  • Verify <script> and <style> tags are stripped from blog HTML content by the sanitization schema

🤖 Generated with Claude Code

Jordan and others added 2 commits June 14, 2026 22:06
Switch the blog_articles.content rendering from renderMarkdown to
renderHtml so interactive HTML elements authored in the Directus WYSIWYG
editor render correctly. Adds a renderHtml pipeline that parses HTML via
rehype-parse with a permissive blog-specific sanitization schema.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The normalize module now imports renderHtml instead of renderMarkdown
for blog article content processing. Update the vi.mock, import, and
all references in the test to match.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@JordanChoo JordanChoo merged commit 78fd676 into main Jun 14, 2026
1 check passed
@JordanChoo JordanChoo deleted the feat/blog-content-md-to-html branch June 14, 2026 22:01
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.

1 participant