diff --git a/personal-blog/backend/uploads/20260729_3f14085c.jpg b/personal-blog/backend/uploads/20260729_3f14085c.jpg new file mode 100644 index 0000000..b8e6326 Binary files /dev/null and b/personal-blog/backend/uploads/20260729_3f14085c.jpg differ diff --git a/personal-blog/backend/uploads/thumbnails/thumb_20260729_3f14085c.jpg b/personal-blog/backend/uploads/thumbnails/thumb_20260729_3f14085c.jpg new file mode 100644 index 0000000..2a2f7dc Binary files /dev/null and b/personal-blog/backend/uploads/thumbnails/thumb_20260729_3f14085c.jpg differ diff --git a/skills/notion-api/SKILL.md b/skills/notion-api/SKILL.md new file mode 100644 index 0000000..b0ff4a1 --- /dev/null +++ b/skills/notion-api/SKILL.md @@ -0,0 +1,63 @@ +--- +name: notion-api +description: Use Notion API Python SDK to create pages, append blocks, and manage content in Notion. Triggers on "Notion", "同步到Notion", "notion API". +--- + +# Notion API Python SDK + +Create and populate Notion pages programmatically. + +## Setup + +```bash +pip install notion-client +``` + +Set environment variables: `NOTION_API_KEY` (integration token), `NOTION_PAGE_ID` (parent page ID). + +## Create Page + +```python +from notion_client import NotionClient +import os + +client = NotionClient(auth=os.environ["NOTION_API_KEY"]) +page = client.pages.create( + parent={"page_id": os.environ["NOTION_PAGE_ID"], "type": "page_id"}, + properties={ + "title": [{"type": "text", "text": {"content": "Title"}}] + } +) +page_id = page["id"] +``` + +## Append Blocks + +```python +client.blocks.children.append(block_id=page_id, children=[ + {"type": "heading_2", "heading_2": {"rich_text": [{"type": "text", "text": {"content": "Section"}}]}}, + {"type": "paragraph", "paragraph": {"rich_text": [{"type": "text", "text": {"content": "Text."}}]}}, + {"type": "code", "code": {"language": "python", "rich_text": [{"type": "text", "text": {"content": "code"}}]}}, +]) +``` + +## Column Layout + +Content goes in nested `children` of `column`/`column_2` inside `column_list`: + +```python +{"type": "column_list", "column_list": {"children": [ + {"type": "column", "column": {"children": [left_block]}}, + {"type": "column", "column": {"children": [right_block]}}, +]}} +``` + +## Block Types + +- `heading_1/2/3`, `paragraph`, `code` (with `language`), `bulleted_list_item`, `numbered_list_item` +- `column_list` / `column`, `bookmark`, `divider`, `to_do`, `callout` +- Rich text: `{"type": "text", "text": {"content": "..."}, "annotations": {"bold": true}}` + +## Database Pages + +Properties must match the database schema exactly — unknown keys cause `ValidationError`.