Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .github/workflows/md-to-notion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- 'docs/**/*.md'

permissions:
contents: read
contents: write

jobs:
sync:
Expand Down Expand Up @@ -39,3 +39,13 @@ jobs:

- name: Sync docs to Notion
run: python3 scripts/md_to_notion.py

- name: Commit updated sync maps
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add 'docs/**/.notion-sync.json' || git add docs/
if ! git diff --staged --quiet; then
git commit -m "chore: .notion-sync.json 업데이트 (md→Notion 동기화)"
git push
fi
16 changes: 8 additions & 8 deletions .github/workflows/notion-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,49 +49,49 @@ jobs:

if [ -n "$_BLOG_DB" ]; then
NOTION_DATABASE_ID="$_BLOG_DB" SAVE_DIR=docs/blog FETCH_MODE=ALL \
python scripts/notion_to_docs_generic.py &
python scripts/notion_to_md.py &
pids+=($!)
fi

if [ -n "$_CONTRIBUTE_DB" ]; then
NOTION_DATABASE_ID="$_CONTRIBUTE_DB" SAVE_DIR=docs/contribute FETCH_MODE=ALL \
python scripts/notion_to_docs_generic.py &
python scripts/notion_to_md.py &
pids+=($!)
fi

if [ -n "$_ABOUT_DB" ]; then
NOTION_DATABASE_ID="$_ABOUT_DB" SAVE_DIR=docs/about FETCH_MODE=ALL \
python scripts/notion_to_docs_generic.py &
python scripts/notion_to_md.py &
pids+=($!)
fi

if [ -n "$_ARCHITECTURE_DB" ]; then
NOTION_DATABASE_ID="$_ARCHITECTURE_DB" SAVE_DIR=docs/architecture FETCH_MODE=ALL \
python scripts/notion_to_docs_generic.py &
python scripts/notion_to_md.py &
pids+=($!)
fi

if [ -n "$_POC_DB" ]; then
NOTION_DATABASE_ID="$_POC_DB" SAVE_DIR=docs/poc FETCH_MODE=ALL \
python scripts/notion_to_docs_generic.py &
python scripts/notion_to_md.py &
pids+=($!)
fi

if [ -n "$_DOCS_DB" ]; then
NOTION_DATABASE_ID="$_DOCS_DB" SAVE_DIR=docs/guide FETCH_MODE=ALL \
python scripts/notion_to_docs_generic.py &
python scripts/notion_to_md.py &
pids+=($!)
fi

if [ -n "$_RELEASE_DB" ]; then
NOTION_DATABASE_ID="$_RELEASE_DB" SAVE_DIR=docs/release-notes FETCH_MODE=ALL \
python scripts/notion_to_docs_generic.py &
python scripts/notion_to_md.py &
pids+=($!)
fi

if [ -n "$_INSTALL_DB" ]; then
NOTION_DATABASE_ID="$_INSTALL_DB" SAVE_DIR=docs/install FETCH_MODE=ALL \
python scripts/notion_to_docs_generic.py &
python scripts/notion_to_md.py &
pids+=($!)
fi

Expand Down
261 changes: 223 additions & 38 deletions CLAUDE.md

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions docs/about/.notion-sync.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
{
"365e15b4-0359-8017-817e-d1e2699828db": {
"file": "docs/about/테스트로-이름-수정.md",
"last_edited": "2026-05-27T01:55:00.000Z",
"content_hash": "b22a39afc99500a5db384d3bdddde5322211bc7b86339689ba982806ac05a3a8",
"last_edited": "2026-05-27T04:08:00.000Z",
"content_hash": "adb4921510a4919dbfae2d89903400fbc238f4e7ef79b1630eb80a9c6efaed5b",
"order": 1,
"parent_id": null
},
"36de15b4-0359-814b-9f2b-ddbefb377eda": {
"file": "docs/about/sbin.md",
"last_edited": "2026-05-27T05:32:00.000Z",
"order": 1,
"parent_id": null
}
Expand Down
13 changes: 13 additions & 0 deletions docs/about/sbin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
id: 테스트로-이름-수정
title: "sbin"
sidebar_position: 1
slug: "1"
---

sbin 이 2026-05-27 14:19 에 수정

## 내용 수정 테스트

이 내용이 Notion에 반영되면 수정 케이스 동작 확인.

15 changes: 7 additions & 8 deletions scripts/md_to_notion.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
source .env && python3 scripts/md_to_notion.py
source .env && SAVE_DIR=docs/about python3 scripts/md_to_notion.py
"""
import hashlib
import json
import os
import re
Expand Down Expand Up @@ -265,6 +264,11 @@ def append_blocks(page_id: str, blocks: list):
_api("patch", f"/blocks/{page_id}/children", json={"children": chunk})


def get_page_last_edited(page_id: str) -> str:
r = _api("get", f"/pages/{page_id}")
return r.json().get("last_edited_time", "")


def update_page_content(page_id: str, blocks: list):
"""기존 블록 전체 삭제 후 새 블록 추가."""
for bid in get_child_block_ids(page_id):
Expand Down Expand Up @@ -316,10 +320,6 @@ def file_to_page_id(sync_map: dict, filepath: str) -> str | None:
return None


def content_hash(text: str) -> str:
return hashlib.sha256(text.encode()).hexdigest()


# ── Git diff ──────────────────────────────────────────────────────────────────

def get_changed_files(section_dir: str) -> dict[str, list[str]]:
Expand Down Expand Up @@ -376,7 +376,7 @@ def process_section(section_dir: str):
blocks = md_body_to_blocks(body)
log(f" [수정] {filepath} → {len(blocks)}개 블록 업로드 중...")
update_page_content(page_id, blocks)
sync_map[page_id]["content_hash"] = content_hash(body)
sync_map[page_id]["last_edited"] = get_page_last_edited(page_id)
sync_dirty = True
log(f" [수정] 완료: {filepath}")

Expand All @@ -396,8 +396,7 @@ def process_section(section_dir: str):
if page_id:
sync_map[page_id] = {
"file": filepath,
"last_edited": "",
"content_hash": content_hash(body),
"last_edited": get_page_last_edited(page_id),
"order": order,
"parent_id": None,
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
notion_to_docs_generic.py — Notion DB → Docusaurus docs 섹션 동기화
notion_to_md.py — Notion DB → Docusaurus docs 섹션 동기화

Env vars (필수):
NOTION_TOKEN Notion API 토큰
Expand Down
16 changes: 8 additions & 8 deletions scripts/server-sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,35 @@ pids=()

[ -n "$NOTION_ABOUT" ] && \
NOTION_DATABASE_ID="$NOTION_ABOUT" SAVE_DIR=docs/about FETCH_MODE=ALL \
python3 scripts/notion_to_docs_generic.py & pids+=($!)
python3 scripts/notion_to_md.py & pids+=($!)

[ -n "$NOTION_ARCHITECTURE" ] && \
NOTION_DATABASE_ID="$NOTION_ARCHITECTURE" SAVE_DIR=docs/architecture FETCH_MODE=ALL \
python3 scripts/notion_to_docs_generic.py & pids+=($!)
python3 scripts/notion_to_md.py & pids+=($!)

[ -n "$NOTION_BLOG" ] && \
NOTION_DATABASE_ID="$NOTION_BLOG" SAVE_DIR=docs/blog FETCH_MODE=ALL \
python3 scripts/notion_to_docs_generic.py & pids+=($!)
python3 scripts/notion_to_md.py & pids+=($!)

[ -n "$NOTION_CONTRIBUTE" ] && \
NOTION_DATABASE_ID="$NOTION_CONTRIBUTE" SAVE_DIR=docs/contribute FETCH_MODE=ALL \
python3 scripts/notion_to_docs_generic.py & pids+=($!)
python3 scripts/notion_to_md.py & pids+=($!)

[ -n "$NOTION_DOCS" ] && \
NOTION_DATABASE_ID="$NOTION_DOCS" SAVE_DIR=docs/guide FETCH_MODE=ALL \
python3 scripts/notion_to_docs_generic.py & pids+=($!)
python3 scripts/notion_to_md.py & pids+=($!)

[ -n "$NOTION_INSTALL" ] && \
NOTION_DATABASE_ID="$NOTION_INSTALL" SAVE_DIR=docs/install FETCH_MODE=ALL \
python3 scripts/notion_to_docs_generic.py & pids+=($!)
python3 scripts/notion_to_md.py & pids+=($!)

[ -n "$NOTION_POC" ] && \
NOTION_DATABASE_ID="$NOTION_POC" SAVE_DIR=docs/poc FETCH_MODE=ALL \
python3 scripts/notion_to_docs_generic.py & pids+=($!)
python3 scripts/notion_to_md.py & pids+=($!)

[ -n "$NOTION_RELEASE" ] && \
NOTION_DATABASE_ID="$NOTION_RELEASE" SAVE_DIR=docs/release-notes FETCH_MODE=ALL \
python3 scripts/notion_to_docs_generic.py & pids+=($!)
python3 scripts/notion_to_md.py & pids+=($!)

# 모든 동기화 완료 대기
failed=0
Expand Down
16 changes: 8 additions & 8 deletions scripts/sync-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,52 +23,52 @@ pids=()
BLOG_DB="${NOTION_BLOG:-$NOTION_DATABASE_ID}"
if [ -n "$BLOG_DB" ]; then
NOTION_DATABASE_ID="$BLOG_DB" SAVE_DIR=docs/blog FETCH_MODE="$FETCH_MODE" \
python scripts/notion_to_docs_generic.py &
python scripts/notion_to_md.py &
pids+=($!)
fi

# Contribute
CONTRIBUTE_DB="${NOTION_CONTRIBUTE:-$NOTION_CONTRIBUTE_DATABASE_ID}"
if [ -n "$CONTRIBUTE_DB" ]; then
NOTION_DATABASE_ID="$CONTRIBUTE_DB" SAVE_DIR=docs/contribute FETCH_MODE=ALL \
python scripts/notion_to_docs_generic.py &
python scripts/notion_to_md.py &
pids+=($!)
fi

# Generic docs sections
if [ -n "$NOTION_ABOUT" ]; then
NOTION_DATABASE_ID="$NOTION_ABOUT" SAVE_DIR=docs/about FETCH_MODE=ALL \
python scripts/notion_to_docs_generic.py &
python scripts/notion_to_md.py &
pids+=($!)
fi

if [ -n "$NOTION_ARCHITECTURE" ]; then
NOTION_DATABASE_ID="$NOTION_ARCHITECTURE" SAVE_DIR=docs/architecture FETCH_MODE=ALL \
python scripts/notion_to_docs_generic.py &
python scripts/notion_to_md.py &
pids+=($!)
fi

if [ -n "$NOTION_POC" ]; then
NOTION_DATABASE_ID="$NOTION_POC" SAVE_DIR=docs/poc FETCH_MODE=ALL \
python scripts/notion_to_docs_generic.py &
python scripts/notion_to_md.py &
pids+=($!)
fi

if [ -n "$NOTION_DOCS" ]; then
NOTION_DATABASE_ID="$NOTION_DOCS" SAVE_DIR=docs/guide FETCH_MODE=ALL \
python scripts/notion_to_docs_generic.py &
python scripts/notion_to_md.py &
pids+=($!)
fi

if [ -n "$NOTION_RELEASE" ]; then
NOTION_DATABASE_ID="$NOTION_RELEASE" SAVE_DIR=docs/release-notes FETCH_MODE=ALL \
python scripts/notion_to_docs_generic.py &
python scripts/notion_to_md.py &
pids+=($!)
fi

if [ -n "$NOTION_INSTALL" ]; then
NOTION_DATABASE_ID="$NOTION_INSTALL" SAVE_DIR=docs/install FETCH_MODE=ALL \
python scripts/notion_to_docs_generic.py &
python scripts/notion_to_md.py &
pids+=($!)
fi

Expand Down
Loading