fix(admin): strip YAML frontmatter before mistune in _rebuild_article()

Fixes a bug where manual article previews rendered raw frontmatter
(title:, slug:, etc.) as visible text. Now strips the --- block using
the existing _FRONTMATTER_RE before passing the body to mistune.html().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Deeman
2026-02-28 22:17:44 +01:00
parent 81ec8733c7
commit 6aae92fc58

View File

@@ -2769,7 +2769,10 @@ async def _rebuild_article(article_id: int):
md_path = Path("data/content/articles") / f"{article['slug']}.md"
if not md_path.exists():
return
body_html = mistune.html(md_path.read_text())
raw = md_path.read_text()
m = _FRONTMATTER_RE.match(raw)
body = raw[m.end():] if m else raw
body_html = mistune.html(body)
lang = article.get("language", "en") if hasattr(article, "get") else "en"
body_html = await bake_scenario_cards(body_html, lang=lang)
body_html = await bake_product_cards(body_html, lang=lang)