Jan 7, 2023

Mistakes of the Past

At some point when building out this blog I made the clever (but not smart) decision to match Next‘s page folder structure with my content. So when generating all the routes for this site, I’d get all the content from the blog folder, the parse out the year and month from the path of the item, and that’s the url of the post.

For example, if I saved a file at: content/blog-posts/2023/01/mistakes-of-the-past

It would show up at blog-posts/2023/01/mistakes-of-the-past. Which is ok, but over time I found these issues with it:

  • Automating generating new content is unnecessarily cumbersome (e.g. as a Shortcuts shortcut), as you can’t just throw it into /blog-posts and call it a day, you have to put it in year/month/post. Also every post already has the full date in the YAML frontmatter so it’s duplicating dates. More to the point, if you move the content it might disappear / break everything.
  • Content couldn’t be stored in a folder that was easily readable to me, the author of the content. I wanted a “drafts” folder for draft content I can view locally, but it was instead scattered around the year/month folders.
  • Generating the slug from the file name is also annoying, because it means the filenames had to be slug friendly. I’ve switched to slugify-ing the post titles now, although I’ll likely add a slug property to the YAML frontmatter to decouple it entirely.

Other things left to fix:

  • The codebase is about half TypeScript files, half JavaScript files.
  • Other types of content are generated by folder path as well. So book notes have their own book-notes folder when they should just have a post-type property.

Am I starting to wish I kept some of this in a database? No… nope. Not yet. Nope.

Comments? Questions? Just want to say hi? Get in touch.

Back to top