将本地 Markdown 文件完整同步到 Notion 页面,保持图文排版顺序。
当用户表达以下需求时,加载此技能:
# 基本用法
.\scripts\sync-to-notion.ps1 -MdFile "C:\path\to\file.md" -PageId "notion-page-id"
# 清空页面后上传
.\scripts\sync-to-notion.ps1 -MdFile "C:\path\to\file.md" -PageId "notion-page-id" -ClearPage
用户必须先配置 Notion API Token。引导用户查看 references/SETUP_TOKEN.md。
快速检查:
$token = & "scripts\get-token.ps1"
if ($token) { Write-Host "Token 已配置" } else { Write-Host "请先配置 Token" }
获取方式:
https://www.notion.so/workspace/PageName-1234567890abcdef页面必须分享给 Integration(Notion 页面设置 → Add connections)
| Markdown | Notion Block | 说明 | |||
|---|---|---|---|---|---|
| ---------- | -------------- | ------ | |||
# ~ ### | heading_1 ~ heading_3 | 原生支持 | |||
#### | callout + 📌 | 模拟 H4 | |||
##### | paragraph + ▶ 加粗 | 模拟 H5 | |||
###### | quote | 模拟 H6 | |||
`lang ` | code | 语言映射 + 超长拆分 | |||
| ` | a | b | ` | table | 表格 |
!alt | image | 本地图片上传 | |||
- item | bulleted_list_item | 无序列表 | |||
1. item | numbered_list_item | 有序列表 | |||
> quote | quote | 引用块 | |||
--- | divider | 分割线 | |||
bold | annotations.bold | 粗体 | |||
italic | annotations.italic | 斜体 | |||
` code ` | annotations.code | 行内代码 | |||
text | link | 链接 |
{
"type": "table",
"table": {
"table_width": 3,
"has_column_header": true,
"children": [{ "type": "table_row", "table_row": { "cells": [[{...}]] } }]
}
}
rows 属性 → 报错children 属性cells 是二维数组(rich_text 数组的数组)rich_text: [[...]] 双层数组 → 报错rich_text: [...] 单层数组workspace_id 作 parent → 404脚本会自动处理以下错误:
更多错误排查见 references/troubleshooting.md
共 1 个版本