将Notion页面转换为WordPress(Gutenberg)HTML
高级
这是一个Content Creation领域的自动化工作流,包含 17 个节点。主要使用 Set, Code, Filter, Notion, Aggregate 等节点。 将Notion页面转换为WordPress(Gutenberg)HTML
前置要求
- •Notion API Key
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "7eb33f3b90daa426f859ca3ba78306e8f7bedb062192407b5811dc8aa23756f7"
},
"nodes": [
{
"id": "863c7ba9-dcbe-4cbb-a451-aff131934ef1",
"name": "获取数据库页面",
"type": "n8n-nodes-base.notion",
"position": [
-448,
208
],
"parameters": {
"pageId": {
"__rl": true,
"mode": "url",
"value": "={{ $json.notion_url }}"
},
"resource": "databasePage",
"operation": "get"
},
"credentials": {
"notionApi": {
"id": "qp3qy2hW4zRFnDmZ",
"name": "Notion account"
}
},
"typeVersion": 2.2
},
{
"id": "80ccc7d0-f503-48c3-bf8f-5c98edcbe543",
"name": "获取多个子块",
"type": "n8n-nodes-base.notion",
"position": [
-224,
208
],
"parameters": {
"blockId": {
"__rl": true,
"mode": "url",
"value": "={{ $json.url }}"
},
"resource": "block",
"operation": "getAll",
"returnAll": true,
"simplifyOutput": false,
"fetchNestedBlocks": true
},
"credentials": {
"notionApi": {
"id": "qp3qy2hW4zRFnDmZ",
"name": "Notion account"
}
},
"typeVersion": 2.2
},
{
"id": "b62bd11d-eafb-49f5-af62-948ea9dea525",
"name": "解码块",
"type": "n8n-nodes-base.code",
"position": [
224,
208
],
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "const c = $json.content\n\nswitch ($json.type) {\n case 'code':\n $json.content = $json.code.text[0].plain_text\n break;\n case 'video':\n if ($json.video.external.url.match('vimeo'))\n // $json.content = `[vimeo src=\"${$json.video.external.url}\"]`\n $json.content = `<!-- wp:shortcode -->[embed]${$json.video.external.url}[/embed]\n<!-- /wp:shortcode -->`\n else if ($json.video.external.url.match('youtu'))\n $json.content = `<!-- wp:shortcode -->\n[embed]${$json.video.external.url}[/embed]\n<!-- /wp:shortcode -->`\n break\n case 'heading_3':\n $json.content = `<!-- wp:heading {\"level\":3} -->\n<h3>${$json.heading_3.text[0].plain_text}</h3>\n<!-- /wp:heading -->`\n break\n case 'heading_2':\n $json.content = `<!-- wp:heading {\"level\":2} -->\n<h2>${$json.heading_2.text[0].plain_text}</h2>\n<!-- /wp:heading -->`\n break\n case 'heading_1':\n $json.content = `<!-- wp:heading {\"level\":2} -->\n<h1>${$json.heading_1.text[0].plain_text}</h1>\n<!-- /wp:heading -->`\n break\n case 'paragraph':\n $json.content = `\n<!-- wp:paragraph -->\n<p>${c}</p>\n<!-- /wp:paragraph -->`\n break\n case 'numbered_list_item':\n $json.content = `\n<!-- wp:list {\"ordered\": true} -->\n<ol class=\\\"wp-block-list\\\">\n<!-- wp:list-item -->\n<li>${c}</li>\n<!-- /wp:list-item -->\n</ol>\n<!-- /wp:list -->`\n break\n case 'bulleted_list_item':\n $json.content = `<!-- wp:list -->\n<ul class=\\\"wp-block-list\\\">\n<!-- wp:list-item -->\n<li>${c}</li>\n<!-- /wp:list-item -->\n</ul>\n<!-- /wp:list -->`\n break\n case 'image':\n $json.content = `<figure class=\"wp-block-image\">\n<img src=\"${$json?.image?.external?.url || $json?.image?.file?.url}\" alt=\"\"/>\n</figure>`\n break\n case 'audio':\n $json.content = `<!-- wp:audio -->\n<figure class=\"wp-block-audio\">\n <audio controls src=\"${$json?.audio?.external?.url || $json?.audio?.file?.url}\"></audio>\n</figure>\n<!-- /wp:audio -->`\n break\n case 'embed':\n $json.content = ` <!-- wp:embed {\"url\":\"${$json.embed.url}\"} /-->`\n break\n case 'divider':\n $json.content = `<hr class=\"wp-block-separator\"/>`\n break\n default:\n $json.content = `<!-- wp:html -->\n${$json.content}\n<!-- /wp:html -->`\n break\n}\n\n\nreturn $json"
},
"typeVersion": 2
},
{
"id": "11fb7b82-a913-4792-a33b-dff0751512af",
"name": "解码段落",
"type": "n8n-nodes-base.code",
"position": [
0,
208
],
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "const annotateText = (t) => {\n let v = t?.text?.content || t.plain_text\n const a = t.annotations\n v = a.bold ? `<strong>${v}</strong>` : v\n v = a.italic ? `<em>${v}</em>` : v\n v = a.strikethrough ? '<s>${v}</s>' : v\n v = a.underline ? '<u>${v}</u>' : v\n if (t?.text?.link) {\n v = `<a href=\"${t.text.link.url}\">${v}</a>`\n }\n return v\n}\n\nswitch ($json.type) {\n case 'paragraph':\n case 'numbered_list_item':\n case 'bulleted_list_item':\n $json.content = $json[$json.type]\n .text\n .map(annotateText)\n .join(' ')\n break\n}\n\nreturn $json"
},
"typeVersion": 2
},
{
"id": "bd2edec6-ffc7-4e80-884d-4fbc9ecb30a7",
"name": "聚合",
"type": "n8n-nodes-base.aggregate",
"position": [
1344,
208
],
"parameters": {
"options": {
"mergeLists": true
},
"fieldsToAggregate": {
"fieldToAggregate": [
{
"fieldToAggregate": "wp"
}
]
}
},
"typeVersion": 1
},
{
"id": "1d83b6b5-9bbe-4a8d-8a79-82ad98b7a28a",
"name": "当由另一个工作流执行时",
"type": "n8n-nodes-base.executeWorkflowTrigger",
"position": [
-672,
304
],
"parameters": {
"workflowInputs": {
"values": [
{
"name": "notion_url"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "1754c892-4aae-46f2-a90c-40fff5d9c88e",
"name": "当点击\"执行工作流\"时",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-896,
112
],
"parameters": {},
"typeVersion": 1
},
{
"id": "03f0e6ad-8a8b-40c0-a392-4441274b61f0",
"name": "编辑字段2",
"type": "n8n-nodes-base.set",
"position": [
-672,
112
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "bb704bf6-9a59-49f0-872b-56469fa52263",
"name": "notion_url",
"type": "string",
"value": ""
}
]
}
},
"typeVersion": 3.4
},
{
"id": "ef9e41a2-38b9-4a9e-87f6-bb19aade231f",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-496,
-176
],
"parameters": {
"color": 6,
"width": 416,
"height": 656,
"content": "## 📥 提取:获取Notion内容"
},
"typeVersion": 1
},
{
"id": "2af6a568-782c-44ed-b04c-5356f67f1139",
"name": "便签 2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-48,
-176
],
"parameters": {
"color": 5,
"width": 880,
"height": 656,
"content": "## ⚙️ 转换:将Notion转换为Gutenberg HTML"
},
"typeVersion": 1
},
{
"id": "18124fd4-c9f7-4ebc-9353-d5fde739cca3",
"name": "丢弃不必要的字段",
"type": "n8n-nodes-base.set",
"position": [
448,
208
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "0630be0c-738a-4f1b-b782-67de592305dc",
"name": "id",
"type": "string",
"value": "={{ $json.id }}"
},
{
"id": "71be8325-4dc1-4567-972a-74ee46c7fe50",
"name": "parent_id",
"type": "string",
"value": "={{ $json.parent_id }}"
},
{
"id": "f1629c55-71fa-4c4f-bb94-c09714827475",
"name": "type",
"type": "string",
"value": "={{ $json.type }}"
},
{
"id": "32db7ae9-9b52-46d8-a75d-61d6e2ba9594",
"name": "content",
"type": "string",
"value": "={{ $json.content }}"
},
{
"id": "efcfcaa9-4e72-4f57-8740-c89a68eceb0c",
"name": "has_children",
"type": "boolean",
"value": "={{ $json.has_children }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "fd03cfb2-3fc1-4dff-ba44-d40d64cb5f5c",
"name": "嵌套块",
"type": "n8n-nodes-base.code",
"position": [
672,
208
],
"parameters": {
"jsCode": "const all = $input.all()\n\nfor (const item of all) {\n if (item.json.type !== 'column') continue\n\n item.json.children = all\n .filter(_ => _.json.parent_id == item.json.id)\n .map(_ => _.json.content)\n .join(\"\\n\")\n item.json.children = \"<!-- wp:column -->\\n<div class=\\\"wp-block-column\\\">\\n\" + item.json.children + \"\\n</div>\\n<!-- /wp:column -->\\n\"\n}\n\nfor (const item of all) {\n if (item.json.type !== 'column_list') continue\n\n item.json.children = all\n .filter(_ => _.json.parent_id == item.json.id)\n .map(_ => _.json.children)\n .join(\"\\n\")\n item.json.children = \"<!-- wp:columns -->\\n<div class=\\\"wp-block-columns\\\">\\n\" + item.json.children + \"\\n</div>\\n<!-- /wp:columns -->\\n\"\n}\n\nreturn all"
},
"typeVersion": 2
},
{
"id": "774f0093-478f-4eb9-979d-0068dba63ff3",
"name": "选择内容字段",
"type": "n8n-nodes-base.set",
"position": [
1120,
208
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "bb93822c-5868-49a4-abbe-d72d8868fc47",
"name": "wp",
"type": "string",
"value": "={{ $json.children || $json.content }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "bbdfd21e-df44-4ad8-b57a-08f6691c8536",
"name": "仅顶级块",
"type": "n8n-nodes-base.filter",
"position": [
896,
208
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "2de1606e-f16f-4455-9c8e-8ccb54ce197c",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.parent_id.replace(/-/g, '') }}",
"rightValue": "={{ $('Get a database page').item.json.id.replace(/-/g,'') }}"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "43a66246-0dfb-445d-b55f-da2c6d8be17a",
"name": "连接行",
"type": "n8n-nodes-base.set",
"position": [
1568,
208
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "b995ade4-ee5c-4d7a-89a5-f01b039f7e62",
"name": "wp",
"type": "string",
"value": "={{ $json.wp.join(\"\\n\") }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "8c7a766d-5499-47d5-abbf-451488ea24be",
"name": "便签 3",
"type": "n8n-nodes-base.stickyNote",
"position": [
848,
-176
],
"parameters": {
"color": 4,
"width": 928,
"height": 656,
"content": "## 🧩 最终确定:组装文章正文"
},
"typeVersion": 1
},
{
"id": "31568ee0-614f-4563-b831-f389e0dc0cef",
"name": "便签 4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1568,
80
],
"parameters": {
"width": 1040,
"height": 400,
"content": "## 🚀 触发器(如何运行)"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"bd2edec6-ffc7-4e80-884d-4fbc9ecb30a7": {
"main": [
[
{
"node": "43a66246-0dfb-445d-b55f-da2c6d8be17a",
"type": "main",
"index": 0
}
]
]
},
"03f0e6ad-8a8b-40c0-a392-4441274b61f0": {
"main": [
[
{
"node": "863c7ba9-dcbe-4cbb-a451-aff131934ef1",
"type": "main",
"index": 0
}
]
]
},
"b62bd11d-eafb-49f5-af62-948ea9dea525": {
"main": [
[
{
"node": "18124fd4-c9f7-4ebc-9353-d5fde739cca3",
"type": "main",
"index": 0
}
]
]
},
"fd03cfb2-3fc1-4dff-ba44-d40d64cb5f5c": {
"main": [
[
{
"node": "bbdfd21e-df44-4ad8-b57a-08f6691c8536",
"type": "main",
"index": 0
}
]
]
},
"11fb7b82-a913-4792-a33b-dff0751512af": {
"main": [
[
{
"node": "b62bd11d-eafb-49f5-af62-948ea9dea525",
"type": "main",
"index": 0
}
]
]
},
"863c7ba9-dcbe-4cbb-a451-aff131934ef1": {
"main": [
[
{
"node": "80ccc7d0-f503-48c3-bf8f-5c98edcbe543",
"type": "main",
"index": 0
}
]
]
},
"774f0093-478f-4eb9-979d-0068dba63ff3": {
"main": [
[
{
"node": "bd2edec6-ffc7-4e80-884d-4fbc9ecb30a7",
"type": "main",
"index": 0
}
]
]
},
"80ccc7d0-f503-48c3-bf8f-5c98edcbe543": {
"main": [
[
{
"node": "11fb7b82-a913-4792-a33b-dff0751512af",
"type": "main",
"index": 0
}
]
]
},
"bbdfd21e-df44-4ad8-b57a-08f6691c8536": {
"main": [
[
{
"node": "774f0093-478f-4eb9-979d-0068dba63ff3",
"type": "main",
"index": 0
}
]
]
},
"18124fd4-c9f7-4ebc-9353-d5fde739cca3": {
"main": [
[
{
"node": "fd03cfb2-3fc1-4dff-ba44-d40d64cb5f5c",
"type": "main",
"index": 0
}
]
]
},
"1d83b6b5-9bbe-4a8d-8a79-82ad98b7a28a": {
"main": [
[
{
"node": "863c7ba9-dcbe-4cbb-a451-aff131934ef1",
"type": "main",
"index": 0
}
]
]
},
"1754c892-4aae-46f2-a90c-40fff5d9c88e": {
"main": [
[
{
"node": "03f0e6ad-8a8b-40c0-a392-4441274b61f0",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 内容创作
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
AI驱动博客自动化
AI驱动博客自动化:使用GPT-4生成并发布SEO文章至WordPress和Twitter
If
Set
Code
+
If
Set
Code
144 节点Jay Emp0
内容创作
WordPress博客自动化专业版(深度研究)v2.1市场
使用GPT-4o、Perplexity AI和多语言支持自动化SEO优化的博客创建
If
Set
Xml
+
If
Set
Xml
125 节点Daniel Ng
内容创作
使用Gemini AI从网站文章自动化社交媒体帖子发布到LinkedIn和X/T
使用Gemini AI从网站文章自动化社交媒体帖子发布到LinkedIn和X/Twitter
If
Set
Xml
+
If
Set
Xml
34 节点Vadim
内容创作
Claude AI、Scrapeless与竞品分析的自动化SEO内容引擎
Claude AI、Scrapeless与竞品分析的自动化SEO内容引擎
Set
Code
Filter
+
Set
Code
Filter
26 节点scrapeless official
内容创作
LinkedIn和X病毒内容自动引擎
使用AI生成和发布自动创建LinkedIn和X的病毒内容
If
Set
Wait
+
If
Set
Wait
156 节点Diptamoy Barman
内容创作
我的智能体竞技场社区竞赛
使用Qdrant、Mistral OCR和GPT-4构建基于RAG的问答系统
Set
Code
Wait
+
Set
Code
Wait
41 节点Davide
内容创作
工作流信息
难度等级
高级
节点数量17
分类1
节点类型8
作者
Konrad Roziewski
@kroziewskiUsing self-hosted n8n since 2022. Specializing in AI, ETL, marketing and product management workflows.
外部链接
在 n8n.io 查看 →
分享此工作流