Generate a web diary from a Notion database with very little configuration!
This is a more opinionated sibling project to Notion Generator. While Notion Generator is able to generate HTML pages from any Notion document, diary generator expect a database of documents structured in a very specific way described below and it will generate a diary from it.
A "web diary" here refers to a website that looks like a diary or a journal where days are tagged with a specific date. If you ever watched or read one of those stories where they go like "Day 74: the storm has shipwrecked half of the fleet..." and you thought to yourself "I WANT TO MAKE SOMETHING LIKE THIS SO BAD AHHHH." Then look no further, friend!
- Start by creating a database in Notion also create an internal integration. Their names don't matter, feel free to name them something that reminds you of their purpose.
- Share your database with your integration by clicking the share menu and then the invite box, your integration should appear for selection.
- Rename the main field in your database to
name
and createdate
,published
fields with type Date andurl
,description
fields with type Text. All of these names are case-sensitive. - Start writing! Each entry in the database should have either one of
date
ORurl
fields filled (NOT both). Having thedate
field turns it into the date's entry. Having theurl
field turns it into an article accessible from/{url}
.
description
gives the entry or article a description. And finallypublished
gives the entry or article a date to be published at. (Before that date it will be automatically skipped) - Once you're ready to publish copy your database's ID and pass it as the only argument, (i.e
./diary-generator 6e0eb85f60474efba1304f92d2abfa2c
) and make sureNOTION_TOKEN
env variable is set to your integration's secret. - Your diary will be generated into
output/
directory and you can do whatever you want with it!
You can arguably avoid the date
field and have a normal blog-like website but that's a bit boring and more people should write public diaries!
For inspiration check my Game Dev Diary where I write about my adventures learning game development!
If you create a pages/
directory in the folder where you handle generation filled with partial HTML files (the main content of the page without the layout AKA head, headers, or footers). Those pages will be automatically copied over to output/
and wrapped in the layout.
The difference between these pages and pages in Notion with url
is that these don't count as articles and won't be listed in the /articles
page. This are useful for pages like /404.html
.
If you create a public/
directory in the folder where you handle generation all its content will be copied over to output/
You can also include a config.json
file in the directory to modify the behavior of the generator. Currently supported fields are:
{
// The name of your diary which will automatically be used in page titles
"name": String,
// The description to use for home page
"description": String,
// Information about the author
"author": {
// If author is present name will be used for <meta name="author"> in all pages
"name": String,
// The URL of the author if they have a personal website they can be found at
"url": String | null
} | null,
// If present will be used for as icon for Atom/RSS feed
// Should be the relative or absolute path to an image, preferably of dimensions 1:1 and small
"icon": String | null,
// If present will be used for as thumbnail for home page using <meta property="og:image">
// Should be the relative or absolute path to an image, preferably of size 1200x630
"cover": String | null,
// The locale of the site following the format `language_TERRITORY` (i.e en_US)
"locale": String,
// The URL where the website will be deployed.
// Used to construct correct <meta property="og:url"> if present
"url": String | null,
// Settings for twitter robot
"twitter": {
// The Twitter tag for this site if one exists (i.e: @MyCoolDiary)
// Corresponds to <meta name="twitter:site">
"site": String | null,
// The Twitter tag for this site's creator if one exists (i.e: @Mathspy)
// Corresponds to <meta name="twitter:creator">
"creator": String | null,
}
}
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in diary generator by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.