gblog
Gblog is a blog engine that pulls posts from a Notion database and persists them in a local sqlite db. Templates are written in pug.
Installation
gleam add gblog@1
gleam add gleam_javascript # to avoid gleam compiler warning
gleam add glen # to avoid gleam compiler warning
# this will copy the following files
#
# ├── blog.db
# ├── Dockerfile
# ├── package.json
# ├── pnpm-workspace.yaml
# └── templates
# ├── index.html.pug
# ├── layout.html.pug
# ├── mixins.pug
# ├── post.html.pug
# └── posts.html.pug
#
# existing files are never overwritten
gleam run -m gblog/init
pnpm install
The copied package.json and pnpm-workspace.yaml files allow to resolve js dependencies(pug, the Notion client, sass, esbuild, …)
from your project root.
Sync posts
Notion database should have the following properties:
titlestatus: status type witht the values “published” and “draft”tags: multiselect typeexcerpt: text typepublished_at: date type
# ensure following env variables are available
# .env or .env.local files are supported
NOTION_API_KEY=
NOTION_DATA_SOURCE_ID=
gleam run -m gblog/sync
Wire your app
[javascript]
runtime = "deno"
[javascript.deno]
# net: the http server
# read/write: sqlite database and templates
# env: APP_ENV, NOTION_API_KEY, NOTION_DATA_SOURCE_ID
# sys: pug reads $HOME through its `resolve` dependency
allow_net = true
allow_read = true
allow_write = true
allow_env = true
allow_sys = true
import gblog
import gblog/context
import gblog/router
import gleam/javascript/promise.{type Promise}
import glen
pub fn main() {
gblog.start(8000, handle_request)
}
fn handle_request(
req: glen.Request,
ctx: context.Ctx,
) -> Promise(glen.Response) {
router.default_routes(req, ctx)
}