✓ เสร็จแล้ว
Obsidian to Astro Exporter
Script แปลง Obsidian vault เป็น Astro Content Collection — ดึง frontmatter, แปลง wikilinks เป็น markdown links, และ copy assets อัตโนมัติ
สารบัญ
ภาพรวม
Obsidian ใช้ wikilink syntax ([[Note Name]]) และ embed syntax (![[image.png]]) ที่ Astro ไม่เข้าใจ โปรเจกต์นี้แปลง vault ทั้งหมดให้อยู่ในรูปแบบที่ Astro Content Collections รับได้ พร้อม frontmatter ที่ถูกต้อง
สิ่งที่ทำ
- รับ path ของ Obsidian vault และ Astro
src/content/เป็น argument - อ่านไฟล์
.mdทั้งหมด parse frontmatter ด้วยgray-matter - แปลง
[[Note Name]]เป็น[Note Name](/notes/note-name) - แปลง
![[image.png]]เป็นและ copy ไฟล์ไปยังpublic/assets/ - ลบ Obsidian-specific frontmatter fields (
cssclass,aliases,banner) - เพิ่ม
dateถ้าไม่มีโดยดูจาก file modification time - dry-run mode: แสดงว่าจะ copy/transform อะไร โดยไม่เขียนไฟล์จริง
Output
vault/
└── Notes/
├── TypeScript Tips.md
└── images/
└── diagram.png
→ src/content/notes/
└── typescript-tips.md (wikilinks แปลงแล้ว)
public/assets/
└── diagram.png
ปัญหาที่เจอ
Obsidian อนุญาตให้ wikilink ข้ามโฟลเดอร์ได้ ([[Note Name]] โดยไม่ระบุ path) ต้องสร้าง index ของ note ทุกตัวก่อน แล้วค้นหาชื่อที่ตรงกัน — ถ้าชื่อซ้ำกันต้องแจ้งเตือนว่า resolve ไม่ได้
เทคโนโลยี
- TypeScript + Node.js 20
gray-matterสำหรับ frontmatter parsingglobสำหรับ file discoverycommanderสำหรับ CLI arguments