A Node.js script to sync your Obsidian notes with your Astro content.
I adapted this script to my own vault and Astro file structures. Here are the requirements for this to work as-is.
- You are using content collections
- All of your images are being dumped into one folder (e.g.
src/content/assets/
)
- Each note contains the following frontmatter keys:
title:
The title of the notepublish:
If set to true, it will be copied to Astrocollection:
Which collection this note belongs toslug:
A chosen slug without the collection (i.e.my-blog-post
notblog/my-blog-post
- Download the repo contents
- Rename
.env.template
to.env
and update the file paths to point to the location of your vault and the images and notes in your Astro site - Run
npm install
- Run
npm run start
to start the script
The script does the following in order:
- Reads all of your Obsidian notes recursively
- Filters out the notes that don't have
slug
,collection
, andpublish: true
defined in their frontmatter - Copies all the images that are used in the published notes to
src/content/assets
- Processes and writes notes one-by-one:
- Converts wikilinks to Markdown links (image wikilinks, too)
- If the link points to another published note, it is replaced with an anchor link to that note
- If it points to a private note in your vault, the link syntax (
[[ ]]
) is removed
- Removes everything under a
## Highlights
heading - Writes note to
src/content/{collection}/{slug}.md
- Converts wikilinks to Markdown links (image wikilinks, too)
- Watches your vault for changes and additions
This is a fork from Rach Smith's version. I adapted her project to fit my specific vault structure. Huge thank you to her for doing most of the work.