Skip to content

Commit 3863243

Browse files
committed
Update hashnode.py
1 parent 1c7c9a4 commit 3863243

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

scripts/hashnode.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,17 +238,25 @@ def sync_posts():
238238
}
239239
}
240240
"""
241+
242+
# 修正点:将 originalPublishDate 改为 publishedAt
243+
input_data = {
244+
"publicationId": pub_id,
245+
"title": title,
246+
"subtitle": description,
247+
"contentMarkdown": body,
248+
"slug": slug,
249+
"tags": tags_input
250+
}
251+
252+
# 只有当时间存在时才加入 publishedAt 字段
253+
if original_publish_date:
254+
input_data["publishedAt"] = original_publish_date
255+
241256
variables = {
242-
"input": {
243-
"publicationId": pub_id,
244-
"title": title,
245-
"subtitle": description,
246-
"contentMarkdown": body,
247-
"slug": slug,
248-
"originalPublishDate": original_publish_date,
249-
"tags": tags_input
250-
}
257+
"input": input_data
251258
}
259+
252260
try:
253261
run_query(publish_mutation, variables)
254262
print(f"✅ 成功发布: {slug}")

0 commit comments

Comments
 (0)