Feeds five ways

A large, properly-formatted data file

Astro comes with a built-in RSS component. The starter theme for this blog originally used that, but I found it kind of limited. I wanted my feeds to be full-text, and I also wanted an Atom feed.

I went looking on NPM for something that could generate an Atom feed, and I found jpmonette/feed. Since it can also generate RSS feeds, I decided it would be best for consistency’s sake to settle on a single feed generator, and ditched Astro’s RSS component altogether.

The code that creates the feed object lives in makeFeed.ts. rss.xml.ts and atom.xml.ts call makeFeed and then generate output in the desired format. The library I’m using also supports JSON Feed; I’ve never used any software that cared about this format, but since I can generate it essentially for free, I do, in feed.json.ts. I’ve got links to all three of feeds embedded in my <head> element; there are also regular links to them at the top of the blog index.

I mentioned in the previous post that I wanted to add microformats The blog index is now marked up as an h-feed, and each entry is marked up as an h-entry. This is accomplished by adding additional CSS classes to the existing HTML. These classes are not intended for styling; instead, they indicate which elements should be parsed to generate a machine-readable representation of the content.

Microdata is sort of like a more formal, corporate version of microformats. Instead of using magic CSS class names, microdata is embedded using itemtype and itemprop attributes. Microdata uses schemas defined by Schema.org; there seem to be about a million of them, each with an extensive set of attributes that only an LDAP developer could love. The blog index is marked up as a Blog and each entry is marked up as a BlogPosting. Apparently Gooblebot understands microdata, so hopefully this will help me out in the SEO department.

If you’re interested, the relevant markup for the microformats and microdata used on this site can be seen in blog.astro (the blog index) and BlogPost.astro (the layout for blog posts). So far I’ve just done a minimally viable implementation for both formats; I still need to mark up non-blog pages with the stuff, and make sure authorship is correctly specified everywhere for both formats. I’ve also tweaked the site design and done a lot of fun and exiting things with the way Markdown gets rendered for this site, but that will have to wait for another blog post.