Skip to content

Commit 76839d3

Browse files
audreytclaude
andcommitted
數位公民 tw variant + .alternates workflow linking
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2816063 commit 76839d3

3 files changed

Lines changed: 281 additions & 0 deletions

File tree

.alternates

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Alternate-language pairs (tab-separated).
2+
# Each line links two translations of the same talk.
3+
# The workflow sends alternate_filename in both directions on upload.
4+
2026-03-04-Ciudadanía-Digital.md 2026-03-04-數位公民.md
5+
2026-03-05-Good-enough-gardeners-must-harness-AI-teams-in-the-Year-of-the-Horse.md 2026-03-05-商周專欄-當你的部屬是一群「會社交」的-AI.md
6+
2026-03-13-A-Dialogue-on-Civic-AI.md 2026-03-13-仁工智慧對話.md

.github/workflows/upload-markdown-on-change.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,23 @@ jobs:
6262
event_name = os.environ.get("GITHUB_EVENT_NAME", "")
6363
ref_name = os.environ.get("GITHUB_REF_NAME", "")
6464
65+
# Parse .alternates file: bidirectional map of filename → alternate slug
66+
alternates = {}
67+
alt_path = workspace / ".alternates"
68+
if alt_path.exists():
69+
for line in alt_path.read_text(encoding="utf-8").splitlines():
70+
line = line.strip()
71+
if not line or line.startswith("#"):
72+
continue
73+
parts = line.split("\t")
74+
if len(parts) == 2:
75+
a, b = parts[0].strip(), parts[1].strip()
76+
a_slug = pathlib.Path(a).stem.lower()
77+
b_slug = pathlib.Path(b).stem.lower()
78+
alternates[a] = b_slug
79+
alternates[b] = a_slug
80+
print(f"[debug] loaded {len(alternates)} alternate mappings")
81+
6582
MAX_RETRIES = 3
6683
BASE_DELAY = 2 # seconds
6784
@@ -164,6 +181,9 @@ jobs:
164181
"filename": rel_path,
165182
"markdown": markdown,
166183
}
184+
if rel_path in alternates:
185+
payload["alternate_filename"] = alternates[rel_path]
186+
print(f"[debug] alternate for {rel_path}: {alternates[rel_path]}")
167187
data = json.dumps(payload).encode("utf-8")
168188
req = urllib.request.Request(
169189
endpoint,
@@ -209,6 +229,9 @@ jobs:
209229
"filename": rel_path,
210230
"markdown": markdown,
211231
}
232+
if rel_path in alternates:
233+
payload["alternate_filename"] = alternates[rel_path]
234+
print(f"[debug] alternate for {rel_path}: {alternates[rel_path]}")
212235
data = json.dumps(payload).encode("utf-8")
213236
req = urllib.request.Request(
214237
endpoint,

0 commit comments

Comments
 (0)