Adding Atom support to this website



This site runs the Digital Garden Obsidian plugin by Ole Eskild Skeensen which can be found on GitHub. Ole also provides a template for the repository the plugin needs to do its magic which can be found here.

The Atom functionality is implemented by using the Nunjucks template in src/site/feed.njk. However, there is an escaping bug for all <link> tags. Instead of using 4 backslashes before the closing > you need 5, otherwise the resulting XML will be invalid. So, the correct code looks like this:

{%if meta.siteBaseUrl %}<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:base="{{ meta.siteBaseUrl }}">
    <title>{{ meta.siteName}}</title>
    <link href="{{ meta.siteBaseUrl }}{{ permalink }}" rel="self" /////>
    <link href="{{ meta.siteBaseUrl }}" /////>
    <updated>{{ collections.notes | getNewestCollectionItemDate | dateToRfc3339 }}</updated>

Running into issues with dates

When the code is run locally, the used static site generator Eleventy creates a feed.xml file which can be parsed by RSS and Atom feed readers. It contains the latest posts by date. Eleventy seems to get the dates either from the file system or from the entries in the GitHub history where the above mentioned template is hosted.

When deploying the repository on my hoster of choice Vercel, however, it seems to make a shallow copy of the GitHub repository and doesn't care about file dates at all. The resulting feed.xml now also contains all posts, but with the current build date of the site on the Vercel infrastructure. Even worse, the date gets changed for all posts every time there is a single update on the site and an Eleventy build runs. This breaks the intention of having a feed and only see recent updates in the first place.

Adding an 'updated' property to all posts

So, properties to the rescue. The Nunjucks template looks in every post if it has an updated property and uses this as the modified date of the post. After adding updated properties to all published posts in Obsidian, they still showed up with the wrong date on the site. What now?

The solution is to activate the Let all frontmatter through option in the Global Note Settings section of the Digital Garden plugin options. Just make sure to check all properties of all files for errors before enabling this, otherwise the deploy will fail.

If everything runs through, though, you now have a running Atom setup for your site. Yay!

dg-settings-frontmatter.jpeg