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:
@@ -2769,7 +2769,10 @@ async def _rebuild_article(article_id: int):
|
|||||||
md_path = Path("data/content/articles") / f"{article['slug']}.md"
|
md_path = Path("data/content/articles") / f"{article['slug']}.md"
|
||||||
if not md_path.exists():
|
if not md_path.exists():
|
||||||
return
|
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"
|
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_scenario_cards(body_html, lang=lang)
|
||||||
body_html = await bake_product_cards(body_html, lang=lang)
|
body_html = await bake_product_cards(body_html, lang=lang)
|
||||||
|
|||||||
Reference in New Issue
Block a user