A Metalsmith plugin to create files from a Day One JSON export.
This plugin only works with Day One v2.
Getting your Day One data
Learn how to export your data as JSON from Day One. Don't worry too much about filtering in Day One, since this plugin allows you to filter which journals and entries get built.
After you have the
.zip file, here are the steps to make sure
metalsmith can work with it:
- Extract the
- If it extracts to a directory, you're all good to go
- If it just extracted to a
.jsonfile, put that file inside a directory
metalsmith-dayone-example repo for an example with paginated entries and tags pages.
Hopefully Super Basic Usage
Once you have all your exported Day One data in a directory, just point the
source method at that directory.
This will result in the
destination directory having an
html file for each entry! It will also copy any referenced photos to that directory.
Adding Day One data to an existing site
If you already have a
metalsmith site or want to use Day One data in conjunction with other stuff, you probably don't want to change the
source path. In this case, you can provide a
data option to
metalsmith-dayone to tell it where to look for your data.
Can't you just work with the zip file?
metalsmith-dayone can unzip the
.zip file for you, but it requires that the
source directory exists. If all you want is Day One data with
metalsmith you'll need to point
source at an empty directory.
// Create an empty directory first__dirnamesource'./empty'
Filtering Day One data
metalsmith-dayone can filter which journals and entries get built by passing options to the plugin.
Let's say you have a journal called
Exercise with a ton of entries but you only want to build a site with entries tagged
bike. Here's how you'd do that:
What does this plugin do?
Day One captures a lot of data. From
userActivity.stepCount, well there's a bunch. For this reason, this plugin doesn't do much data parsing except the following:
- Transforms the
textto a buffer (and optionally parses it to
html) and puts it on
- Rewrites any internal Day One links and images to point where they will be in the
titlemetadata based on the best guess from the entry
- Places all other Day One data as if it were read from
Here's an example of some data after
metalsmith-dayone is done with it (with a
'entries/BC5CE1B78AFC4003A1BB0CF5593013C5.html':contents: Buffertext: '# Raw markdown\nStuff'title: 'Raw markdown'tags: 'tag' 'tag3'weather: ...location: ......'photos/123.jpeg':contents: Buffer'entries/E686072CCEE044948295B7C4CF5D1C42.html':contents: Buffertext: '!(/photos/123.jpeg)'title: 'Untitled' // No title for this entrytags: 'tag1' 'tag3'photos: ......
Path to your exported Day One data directory or
If this is not used, it will default to the
path (optional, default:
The path where each entry will be written.
:id will be replaced by the Day One entry id.
layout (optional, default
Specifiy a layout property to be used with each entry. Used for compatibility with
markdown (optional, default
Whether to parse the text of each entry from markdown to html. Based on this property the extension of each file will be
journals (optional, default
String | [String, ...]
Filter which journals get built by doing a case insensitive match on the name of the journal.
By default all journals get built.
tags (optional, default
String | [String, ...]
Filter which entries get built by doing a case insensitive match on the entries' tags.
By default all entries get built.
- I've had one journal where the exported data is always missing a few images even though they are visible inside Day One