When is it best to render files on deploy?

I use Jekyll for my blog, and I use Roam Research for note taking.

I’d like to be able to selectively publish portions of my notes that have been mentioned in posts.

I have a rake task that turns the json blob from Roam into a markdown page for each of my notes into /_notes, complete with front matter, and they render nice. But! I have a ton notes that are very personal, that I do not want on my blog.

I’d like to only render notes that are mentioned from a post.

For example, I have a blog post about how the government replaced all the birds with small drones to spy on us. /_posts/2020-06-06-birds-are-not-real.md. In the post, I reference the following notes:

  • /_notes/operation-overflight--a-memoir-of-the-u-2-incident.md
  • /_notes/rachel-carson--silent-spring---other-writings-on-the-environment.md
  • /_notes/god-and-ronald-reagan--a-spiritual-life.md
  • /_notes/electronic-circuit-design-and-application

My dream build process is on jekyll build:

  1. downloads export from roam.
  2. looks through _posts/ for all links to _notes (cf above). (this is the thing I don’t know how to do)
  3. selectively renders only those pages that are referenced. (this code is already done).
  4. Jekyll builds _posts and _notes/
  5. People reading about birds can see my source material better.

Any suggestions?