<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>踩坑 on Yagu的小站</title><link>https://blog.yagu.ddns-ip.net/tags/%E8%B8%A9%E5%9D%91/</link><description>Recent content in 踩坑 on Yagu的小站</description><generator>Hugo</generator><language>zh-cn</language><lastBuildDate>Fri, 15 May 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://blog.yagu.ddns-ip.net/tags/%E8%B8%A9%E5%9D%91/index.xml" rel="self" type="application/rss+xml"/><item><title>Ghost Admin API 踩坑实录</title><link>https://blog.yagu.ddns-ip.net/posts/ghost-admin-api-pitfalls/</link><pubDate>Fri, 15 May 2026 00:00:00 +0000</pubDate><guid>https://blog.yagu.ddns-ip.net/posts/ghost-admin-api-pitfalls/</guid><description>&lt;p&gt;用 Ghost 6.x Admin API 发布内容时踩的几个坑，记录下来省得下次再踩。&lt;/p&gt;
&lt;h2 id="坑一html-内容神秘消失"&gt;坑一：HTML 内容神秘消失&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;现象：&lt;/strong&gt; 用 &lt;code&gt;POST /ghost/api/admin/posts/&lt;/code&gt; 创建文章，传了 &lt;code&gt;html&lt;/code&gt; 字段，返回成功，但文章正文是空的。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;原因：&lt;/strong&gt; Ghost 6.x 默认期望的内容格式是 &lt;strong&gt;Lexical&lt;/strong&gt;（一种 JSON 结构），不是 HTML。如果你直接传 &lt;code&gt;html&lt;/code&gt; 字段但不告诉 Ghost 这是 HTML，它会静默忽略。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;解决：&lt;/strong&gt; 在 URL 后面加 &lt;code&gt;?source=html&lt;/code&gt;：&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;# 错误——html 被忽略
POST /ghost/api/admin/posts/
# 正确——Ghost 自动把 HTML 转成 Lexical
POST /ghost/api/admin/posts/?source=html
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="坑二api-返回的-html-字段为-null"&gt;坑二：API 返回的 html 字段为 null&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;现象：&lt;/strong&gt; 创建成功后，API 响应里的 &lt;code&gt;html&lt;/code&gt; 字段是 &lt;code&gt;null&lt;/code&gt;，以为内容没存进去。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;原因：&lt;/strong&gt; 这是正常的。Ghost 内部把 HTML 转成了 Lexical JSON 存储，Admin API 响应不返回 HTML 内容。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;验证方法：&lt;/strong&gt; 用 &lt;strong&gt;Content API&lt;/strong&gt;（公开的只读接口）来确认内容是否真的写进去了。&lt;/p&gt;</description></item></channel></rss>