返回顶部
n

notion-syncNotion同步

Bi-directional sync and management for Notion pages and databases. Use when working with Notion workspaces for collaborative editing, research tracking, project management, or when you need to sync markdown files to/from Notion pages or monitor Notion pages for changes.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 2.5.3
安全检测
已通过
3,650
下载量
免费
免费
6
收藏
概述
安装方式
版本历史

notion-sync

Notion 同步

在 Markdown 文件和 Notion 页面之间进行双向同步,并提供用于研究跟踪和项目管理的数据库管理工具。

升级说明

从 v2.0 升级: 将 --token ntn... 替换为 --token-file、--token-stdin 或 NOTIONAPI_KEY 环境变量。不再接受裸 --token 参数(凭证不应出现在进程列表中)。

从 v1.x 升级: 请参阅 v2.0 更新日志了解迁移详情。

系统要求

  • - Node.js v18 或更高版本
  • Notion 集成令牌(以 ntn 或 secret 开头)

设置步骤

  1. 1. 访问 https://www.notion.so/my-integrations
  2. 创建新集成(或使用现有集成)
  3. 复制内部集成令牌
  4. 使用以下方法之一传递令牌(脚本使用的优先级顺序):

选项 A — 令牌文件(推荐):
bash
echo ntnyourtoken > ~/.notion-token && chmod 600 ~/.notion-token
node scripts/search-notion.js query --token-file ~/.notion-token

选项 B — 标准输入管道:
bash
echo $NOTIONAPIKEY | node scripts/search-notion.js query --token-stdin

选项 C — 环境变量:
bash
export NOTIONAPIKEY=ntnyourtoken
node scripts/search-notion.js query

自动默认: 如果 ~/.notion-token 存在,即使不指定 --token-file,脚本也会自动使用它。

  1. 5. 与集成共享您的 Notion 页面/数据库:
- 在 Notion 中打开页面/数据库 - 点击共享→邀请 - 选择您的集成

JSON 输出模式

所有脚本都支持全局 --json 标志。

  • - 抑制写入 stderr 的进度日志
  • 保持 stdout 机器可读,便于自动化
  • 错误以 JSON 格式输出:{ error: ... }

示例:
bash
node scripts/query-database.js --limit 5 --json

路径安全模式

默认情况下,读写本地文件的脚本仅限于当前工作目录。

  • - 防止意外读取/写入预期工作区之外的文件
  • 适用于:md-to-notion.js、add-to-database.js、notion-to-md.js、watch-notion.js
  • 可通过 --allow-unsafe-paths 有意覆盖

示例:
bash

默认(安全):路径必须在当前工作区内


node scripts/md-to-notion.js docs/draft.md Draft

有意覆盖(工作区外)

node scripts/notion-to-md.js ~/Downloads/export.md --allow-unsafe-paths

核心操作

1. 搜索页面和数据库

按标题或内容搜索 Notion 工作区。

bash
node scripts/search-notion.js [--filter page|database] [--limit 10] [--json]

示例:
bash

搜索与通讯稿相关的页面


node scripts/search-notion.js newsletter

仅查找数据库

node scripts/search-notion.js research --filter database

限制结果数量

node scripts/search-notion.js AI --limit 5

输出:
json
[
{
id: page-id-here,
object: page,
title: Newsletter Draft,
url: https://notion.so/...,
lastEdited: 2026-02-01T09:00:00.000Z
}
]

2. 使用筛选条件查询数据库

使用高级筛选和排序功能查询数据库内容。

bash
node scripts/query-database.js [--filter ] [--sort ] [--limit 10] [--json]

示例:
bash

获取所有项目


node scripts/query-database.js xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

按状态 = 完成 筛选

node scripts/query-database.js \ --filter {property: Status, select: {equals: Complete}}

按包含AI的标签筛选

node scripts/query-database.js \ --filter {property: Tags, multi_select: {contains: AI}}

按日期降序排序

node scripts/query-database.js \ --sort [{property: Date, direction: descending}]

组合筛选和排序

node scripts/query-database.js \ --filter {property: Status, select: {equals: Complete}} \ --sort [{property: Date, direction: descending}]

常用筛选模式:

  • - 选择等于:{property: Status, select: {equals: Done}}
  • 多选包含:{property: Tags, multiselect: {contains: AI}}
  • 日期之后:{property: Date, date: {after: 2024-01-01}}
  • 复选框为真:{property: Published, checkbox: {equals: true}}
  • 数字大于:{property: Count, number: {greaterthan: 100}}

3. 更新页面属性

更新数据库页面的属性(状态、标签、日期等)。

bash
node scripts/update-page-properties.js [--type ] [--json]

支持的类型: select、multiselect、checkbox、number、url、email、date、richtext

示例:
bash

设置状态


node scripts/update-page-properties.js Status Complete --type select

添加多个标签

node scripts/update-page-properties.js Tags AI,Leadership,Research --type multi_select

设置复选框

node scripts/update-page-properties.js Published true --type checkbox

设置日期

node scripts/update-page-properties.js Publish Date 2024-02-01 --type date

设置 URL

node scripts/update-page-properties.js Source URL https://example.com --type url

设置数字

node scripts/update-page-properties.js Word Count 1200 --type number

4. 批量更新

在一个命令中跨多个页面批量更新单个属性。

模式 1 — 查询 + 更新:
bash
node scripts/batch-update.js --filter [--type select] [--dry-run] [--limit 100]

示例:
bash
node scripts/batch-update.js Status Review \
--filter {property:Status,select:{equals:Draft}} \
--type select

模式 2 — 从标准输入读取页面 ID:
bash
echo page-id-1\npage-id-2\npage-id-3 | \
node scripts/batch-update.js --stdin [--type select] [--dry-run]

功能特性:

  • - --dry-run:打印将要更新的页面(显示当前属性值)但不实际写入
  • --limit :最大处理页面数(默认 100)
  • 查询模式下的分页(hasmore/nextcursor)直到达到限制
  • 速率限制友好的更新(页面更新间隔 300ms)
  • 进度和摘要输出到 stderr,JSON 结果数组输出到 stdout

5. Markdown → Notion 同步

将 Markdown 内容推送到 Notion,支持完整格式。

bash
node scripts/md-to-notion.js \
\
\
[--json] [--allow-unsafe-paths]

示例:
bash
node scripts/md-to-notion.js \
projects/newsletter-draft.md \
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx \
Newsletter Draft - Feb 2026

支持的格式:

  • - 标题(H1-H3)
  • 粗体/斜体文本
  • 链接
  • 无序列表
  • 带语法高亮的代码块
  • 水平分隔线

-

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 notion-sync-1776351083 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 notion-sync-1776351083 技能

通过命令行安装

skillhub install notion-sync-1776351083

下载

⬇ 下载 notion-sync v2.5.3(免费)

文件大小: 27.56 KB | 发布时间: 2026-4-17 15:16

v2.5.3 最新 2026-4-17 15:16
Workspace path safety guard + docs hardening; keeps scanner-aligned metadata and credential-safe token handling.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部