beeminder / blog

3 stars 2 forks source link

Quick Links

Blog Post Ideas

Ideas for new blog posts live here as gissues. Danny curates the collection via freshgishing aka backlog freshening.

Adding a New Blog Post

Just add the raw source URL to posts.json in this repository and merge to master! Merging to master triggers a deploy on Render.com. You can also click Manual Deploy on the Render.com dashboard or hit a magic deploy URL that Render.com provides.

Post Markdown

All Markdown extended features documented at doc.bmndr.co are supported.

The frontmatter aka metadata for each post can either be in that posts.json file or as a YAML block at the very top of the source file:

--- # nothing above this line
title: The Title of the Post
slug: title-of-post
date: 2021-01-01
author: dreeves
tags: [tag1, tag2]
status: publish # publish or draft or pending
disqus_id: any-unique-string
redirects: [old-slug]
excerpt: >
  The excerpt is used for the post preview on the blog index page.
  It can be multiple lines long.
  All HTML and markdown will be stripped.
---
The actual content of the post goes here.
The usual begin/end-magic strings from etherpad apply.

Using the YAML frontmatter is tentatively deprecated.

Development

nvm use
pnpm install
pnpm run dev

Fetch requests are cached to the .cache directory during local development. To clear the cache, run pnpm run cache:clear. To disable this behavior, add FILE_SYSTEM_CACHE="false" to a .env file in the project root.

Testing

pnpm run test
pnpm run test:snapshots
# Once you've verified any snapshot changes are correct, update them with:
pnpm run test:snapshots:update

Always err on the side of writing unit tests rather than snapshot tests. Snapshot tests are unweildy, slow, and brittle. They should only be used for things that are hard to unit test, For example, checking that a change doesn't break any posts in the blog's large backlog would be impractical to do with unit tests. So we do so with snapshot tests.

Also note that you may need to run pnpm run cache:clear to sync your local cache with any upstream raw source changes. If you fail to do so and push to GitHub, one or more snapshot tests may fail as obsolete in GitHub Actions, since each test is identified by a hash of its source.

Production

Commits merged to master are automatically deployed via Render.com.