Recently David Merfield, the developer behind Blot, documented the steps to expose a JSON feed on a Blot site. I have been running a JSON feed for my blog for quite some time now, with some valuable help from David of course. It is this feed that drives the On This Day page on this blog. I thought I will share my approach so that others with a blog running on Blot can create such a page.
To begin with, follow the guide to get a working JSON feed for your blog. Validate you have a properly formed and accessible feed being served using the JSON feed validator.
One key thing to understand here is how to create a view in Blot. It would be important to be aware of this step to proceed further. A view can be created in Blot by accessing the editing template
) in Blot dashboard. Click on Edit
against your currently installed theme and search for an option “Create new view”
tz variables appropriately to reflect the URL for the JSON feed and the timezone for your blog, you can refer to the formats in TZ database time zones. This script does the following.
- Fetches all the posts as JSON objects from the JSON feed
- Identifies the posts that share the same date and month as the current date (but not the year to avoid loading today’s posts)
- Renders the posts (or no posts message) in the predefined section detailed below. This also includes some styling via the
.className definition, you can remove/modify that as per your liking in fuction
Make sure the above created view is accessible at a URL. If not, define a route in the Settings section of the view.
Next, create another view for a page to display these posts; a reference html page is available as a gist. Modify the
div element with
Do give this a try, it is fascinating to see your thoughts change, or at times stay exactly the same, over the year. Reach out to me if you face any issues or find any step missing.
Expose a JSON
feed on your site. Create two views in Blot using the gist flashback.js
. You should have two additional pages, you can use the same file names. If you do, you can access your On This Day page at