bmschmidt / bare-bones-blog

A bare-bones, extremely extensible blog using pandoc and svelte-kit
Other
3 stars 0 forks source link

Bare-bones blogging with sveltekit

A blog is a set of essays, by date, with an accompanying Atom or RSS feed.[^1] The best way to write this sort of thing is in Markdown; and the best Markdown processor is Pandoc.

But for as long as I've been on the Web, it's been weirdly difficult to write a blog in pandoc-styled Markdown, with all the benefits that come with it. And the sites that people use for blogging, like Jekyll and Hugo, require you to wade through piles of documentation and configuration to learn how to use them: and once you do, you have learned an obscure markup format in a language that has nothing to do the web.[^2]

This repo extracts out the basic architecture from my personal site into a truly bare-bones blog that can be easily extended. Svelte-kit is a well-thought out way to write performant, accessible, standards-oriented web sites that use Javascript as a templating language, prioritize accessibility and quick build times (unlike, say, Jekyll) and avoid the bloated abstractions of React. Writing in Svelte components is about as close as you can get nowadays to actually using the things you'd learn in a web dev class about CSS, HTML, and Javascript.

You should use a javascript-based build framework for your blog, because love it or hate it-- who am I kidding, obviously you hate it--it's the language of the web and it makes it easier to do webby things. People who like Jekyll sometimes like to call it 'battle-tested.' This is bonkers-- it's like if you had to had to choose one country's Olympic team to protect your home and blurted out 'Persia!' because you remember how scary they were in the movie 300.[^3] First off, that was a long time ago, and there are a lot of Russians on steroids and Americans on marginally less detectable PEDs you might want to consider first. Second of all, they lost the war. So did Jekyll, friends. If you've been using it since 2012, by all means keep it going. But for the love of God, don't foist it on other people.

The real point here is to be able to do neat things inside the blocks. For some examples, see the pandoc-svelte-components library I use heavily here. But the point here is minimalism that's fast, flexible, and showcases modern web architecture.

Editing

To make this site your own you'll need to edit a few things:

  1. src/content is where the blog posts live. Write your own!
  2. routes/[format.xml]/+page.server.ts defines the RSS feed on top of those posts. Lots of frameworks out there would have you template all the information there into a YAML file or something. Screw that! Just go edit the code.
  3. The basic svelte files at routes/+layout.svelte and routes/[...slug]/+page.svelte to define how the pages should look.
  4. src/app.css to configure global styles (although note that in svelte you can edit almost all the css you might need inside the files themselves.)

Building

To build the site you must have a system version of pandoc. I have some hopes for getting around this, but for now it's a hard must. Once you do:

git clone https://bmschmidt.github.io/bare-bones-blog/atom.xml
npm i
npm run dev # <- for while you edit--if you haven't used vite,
            # it's worth watching how quickly style/code changes apply.
            # This will give you a link to view.
            # Change the markdown files in src/content.

##BUILD##
npm run build # <- to build the static-page version.
## OR ###
npm run deploy # <- builds the static-page version, commits it to a separate branch called gh-pages, and uploads to github.

Full list of files

All the files in this project--more or less--are below. The ones in bold are ones you might have to actually edit.

Notes

[^1]: Yes, there were blogs before there was RSS. And there were eggs before chickens. But if you serve me an omelet, I'm going to assume it's made of chicken eggs; if it turns out to be made with salmon roe or alligator eggs, there's something wrong with you.

[^2]: Something that's always puzzled me is how there isn't a dominant one of these things everyone uses written in Python, even though there's a whole industry devoted to convincing people to learn to code in Python. Like there's django--which I also don't think you should use--and there are some things--I want to say Pelican?--but basically nothing.

[^3]: I haven't actually seen the movie 300, because... I mean so many reasons. It looks kind of racist, first off.