notion-md-sync

👤 user_8dfc0ef3 📦 v1.0.0 ⭐ 4.0 ⬇️ 297 下載
📚 知識管理 免費 🔑 需 API Key

📖 技能介紹


name: notion-md-sync description: "將本地 Markdown 檔案同步到 Notion 頁面。當用戶需要將 MD 檔案上傳到 Notion、遷移本地筆記到 Notion、或批次匯入 Markdown 內容時使用此技能。支援完整 Markdown 語法:標題、程式碼塊、表格、圖片、列表等。" metadata: {"openclaw": {"emoji": "📝"}}


Notion Markdown 同步技能

將本地 Markdown 檔案完整同步到 Notion 頁面,保持圖文排版順序。

觸發條件

當用戶表達以下需求時,載入此技能:

  • "把 Markdown 檔案上傳到 Notion"
  • "同步本地筆記到 Notion"
  • "匯入 MD 檔案到 Notion"
  • "把 xxx.md 放到 Notion"
  • "遷移筆記到 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

前置條件

1. Notion Token

使用者必須先配置 Notion API Token。引導使用者檢視 references/SETUP_TOKEN.md

快速檢查

$token = & "scripts\get-token.ps1"
if ($token) { Write-Host "Token 已配置" } else { Write-Host "請先配置 Token" }

2. 頁面 ID

獲取方式: - 從 URL 複製:https://www.notion.so/workspace/PageName-1234567890abcdef - 使用搜索 API 查詢

3. 頁面許可權

頁面必須分享給 Integration(Notion 頁面設定 → Add connections)

支援的 Markdown 語法

Markdown Notion Block 說明
# ~ ### heading_1 ~ heading_3 原生支援
#### callout + 📌 模擬 H4
##### paragraph + ▶ 加粗 模擬 H5
###### quote 模擬 H6
```lang ``` code 語言對映 + 超長拆分
| a | b | table 表格
![alt](path) image 本地圖片上傳
- item bulleted_list_item 無序列表
1. item numbered_list_item 有序列表
> quote quote 引用塊
--- divider 分割線
**bold** annotations.bold 粗體
*italic* annotations.italic 斜體
`code` annotations.code 行內程式碼
[text](url) link 連結

關鍵坑點

1. 表格格式

{
  "type": "table",
  "table": {
    "table_width": 3,
    "has_column_header": true,
    "children": [{ "type": "table_row", "table_row": { "cells": [[{...}]] } }]
  }
}
  • ❌ 用 rows 屬性 → 報錯
  • ✅ 用 children 屬性
  • cells 是二維陣列(rich_text 陣列的陣列)

2. rich_text 陣列

小蔥技能7w4.net有完整的技能分類。

  • rich_text: [[...]] 雙層陣列 → 報錯
  • rich_text: [...] 單層陣列

3. 程式碼塊長度

  • 單個 code Block 最多 2000 字元
  • 指令碼會自動拆分超長程式碼塊

4. 頁面 ID

  • ❌ 用 workspace_id 作 parent → 404
  • ✅ 用搜索 API 找有效頁面

詳細文件

  • README.md — 安裝和使用指南
  • references/SETUP_TOKEN.md — Token 配置詳解
  • references/notion-api.md — Notion Block API 參考
  • references/troubleshooting.md — 9 類常見問題排查

執行流程

  1. 獲取 Token — 檢查環境變數/配置檔案/平臺託管
  2. 驗證檔案 — 確認 MD 檔案存在
  3. 清空頁面(可選)— 刪除現有 Block
  4. 預上傳圖片 — 上傳本地圖片到 Notion 檔案儲存
  5. 構建 Block — 解析 Markdown,轉換為 Notion 格式
  6. 分批上傳 — 每批 50 個 Block,避免 API 限制
  7. 完成報告 — 顯示成功/失敗數量

錯誤處理

指令碼會自動處理以下錯誤:

  • Token 未配置 → 提示配置方法
  • 檔案不存在 → 提示路徑
  • API 限流 → 自動重試
  • 超長程式碼塊 → 自動拆分

更多錯誤排查見 references/troubleshooting.md

🤖 AI 評測

這個工具功能描述清晰、文件詳細,但存在嚴重缺陷——主指令碼檔案缺失,安裝後可能無法正常使用。重新命名腳本里還殘留了一些測試資料,不夠專業。總體來說完成度不夠,建議等待修復後再使用。

📊 多維度評分

適應性4.4
規範性4.3
有效性3.5
可靠性3.6
可信度4.8

📁 包含檔案 (6 個)

📄 README.md 4.4 KB
📄 SKILL.md 3.8 KB
📄 references/SETUP_TOKEN.md 2.4 KB
📄 references/notion-api.md 3.8 KB
📄 references/troubleshooting.md 19 KB
📄 scripts/rename-page.py 5.8 KB