• Stars
    star
    117
  • Rank 292,409 (Top 6 %)
  • Language
    Clojure
  • License
    MIT License
  • Created almost 2 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Light-weight static blog engine for Clojure and babashka

Quickblog

The blog code powering my blog.

See API.md on how to use this.

Compatible with babashka and Clojure.

Includes hot-reload. See it in action here.

Blogs using quickblog

Instances of quickblog can be seen here:

Feel free to PR yours.

Quickstart

Babashka

quickblog is meant to be used as a library from your Babashka project. The easiest way to use it is to add a task to your project's bb.edn.

This example assumes a basic bb.edn like this:

{:deps {io.github.borkdude/quickblog
        #_"You use the newest SHA here:"
        {:git/sha "389833f393e04d4176ef3eaa5047fa307a5ff2e8"}}
 :tasks
 {:requires ([quickblog.cli :as cli])
  :init (def opts {:blog-title "REPL adventures"
                   :blog-description "A blog about blogging quickly"})
  quickblog {:doc "Start blogging quickly! Run `bb quickblog help` for details."
             :task (cli/dispatch opts)}}}

To create a new blog post:

$ bb quickblog new --file "test.md" --title "Test"

To start an HTTP server and re-render on changes to files:

$ bb quickblog watch

Clojure

Quickblog can be used in Clojure with the exact same API as the bb tasks. Default options can be configured in :exec-args.

:quickblog
{:deps {io.github.borkdude/quickblog
        #_"You use the newest SHA here:"
        {:git/sha "389833f393e04d4176ef3eaa5047fa307a5ff2e8"}
        org.babashka/cli {:mvn/version "0.3.35"}}
 :main-opts ["-m" "babashka.cli.exec" "quickblog.cli" "run"]
 :exec-args {:blog-title "REPL adventures"
             :blog-description "A blog about blogging quickly"}}

After configuring this, you can call:

$ clj -M:quickblog new --file "test.md" --title "Test"

To watch:

$ clj -M:quickblog watch

etc.

Features

Markdown

Posts are written in Markdown and processed by markdown-clj, which implements the MultiMarkdown flavour of Markdown.

Metadata

Post metadata is specified in the post file using MultiMarkdown's metadata tags. quickblog expects three pieces of metadata in each post:

  • Title - the title of the post
  • Date - the date when the post will be published (used for sorting posts, so ISO 8601 datetimes are recommended)
  • Tags - a comma-separated list of tags

quickblog new requires the title to be specified and provides sensible defaults for Date and Tags.

You can add any metadata fields to posts that you want. See the Social sharing section below for some useful suggestions.

Note: metadata may not include newlines!

favicon

NOTE: when enabling or disabling a favicon, you must do a full re-render of your site by running bb quickblog clean and then your bb quickblog render command.

To enable a favicon, add :favicon true to your quickblog opts (or use --favicon true on the command line). quickblog will render the contents of templates/favicon.html and insert them in the head of your pages.

You will also need to create the favicon assets themselves. The easiest way is to use a favicon generator such as RealFaviconGenerator, which will let you upload an image and then gives you a ZIP file containing all of the assets, which you should unzip into your :assets-dir (which defaults to assets).

You can read an example of how to prepare a favicon here: https://jmglov.net/blog/2022-07-05-hacking-blog-favicon.html

quickblog's default template expects the favicon files to be named as follows:

  • android-chrome-192x192.png
  • android-chrome-512x512.png
  • apple-touch-icon.png
  • browserconfig.xml
  • favicon-16x16.png
  • favicon-32x32.png
  • favicon.ico
  • mstile-150x150.png
  • safari-pinned-tab.svg
  • site.webmanifest

If any of these files are not present in your :assets-dir, a quickblog default will be copied there from resources/quickblog/assets.

Social sharing

Social media sites such as Facebook, Twitter, LinkedIn, etc. display neat little preview cards when you share a link. These cards are populated from certain <meta> tags (as described in "How to add a social media share card to any website", by Michelle Mannering) and typically contain a title, description / summary, and preview image.

quickblog's base template adds meta tags for the page title for all pages and descriptions for the following pages:

  • Index: {{blog-description}}
  • Archive: Archive - {{blog-description}}
  • Tags: Tags - {{blog-description}}
  • Tag pages: Posts tagged "{{tag}}" - {{blog-description}}

If you specify a :blog-image URL option, a preview image will be added to the index, archive, tags, and tag pages. The URL should point to an image; for best results, the image should be 1200x630 and maximum 5MB in size. It may either be an absolute URL or a URL relative to :blog-root.

For post pages, meta tags will be populated from Title, Description, Image, Image-Alt, and Twitter-Handle metadata in the document.

If not specified, Twitter-Handle defaults to the :twitter-handle option to quickblog. The idea is that the :twitter-handle option is the Twitter handle of the person owning the blog, who is likely also the author of most posts on the blog. If there's a guest post, however, the guest blogger can add their Twitter handle instead.

For example, a post could look like this:

Title: Sharing is caring
Date: 2022-08-16
Tags: demo
Image: assets/2022-08-16-sharing-preview.png
Image-Alt: A leather-bound notebook lies open on a writing desk
Twitter-Handle: quickblog
Description: quickblog now creates nifty social media sharing cards / previews. Read all about how this works and how you can maximise engagement with your posts!

You may have already heard the good news: quickblog is more social than ever!
...

The value of the Image field is either an absolute URL or a URL relative to :blog-root. As noted above, images should be 1200x630 and maximum 5MB in size for best results.

Image-Alt provides alt text for the preview image, which is extremely important for making pages accessible to people using screen readers. I highly recommend reading resources like "Write good Alt Text to describe images" to learn more.

Resources for understanding and testing social sharing:

Templates

quickblog uses the following templates in site generation:

  • base.html - All pages. Page body is provided by the {{body}} variable.
  • post.html - Post bodies.
  • style.css - Styles for all pages.
  • favicon.html - If :favicon true, used to include favicon in the <head> of all pages.
  • tags.html - Tag overview page.
  • post-links.html - Used to render lists of blog posts in the archive and each page corresponding to a single tag.
  • index.html - Index page. Posts containing the marker comment <!-- end-of-preview --> are included on the index page up until the first occurrence of that comment.

quickblog looks for these templates in your :templates-dir, and if it doesn't find them, will copy a default template into that directory. It is recommended to keep :templates-dir under revision control so that you can modify the templates to suit your needs and preferences.

The default templates are occasionally modified to support new features. When this happens, you won't be able to use the new feature without making the same modifications to your local templates. The easiest way to do this is to run bb quickblog refresh-templates.

Breaking changes

posts.edn removed

quickblog now keeps metadata for each blog post in the post file itself. It used to use a posts.edn file for this purpose. If you are upgrading from a version that used posts.edn, you should run bb quickblog migrate and then remove the posts.edn file.

Improvements

Feel free to send PRs for improvements.

My wishlist:

  • There might be a few things hardcoded that still need to be made configurable.
  • Upstream improvements to markdown-clj

More Repositories

1

jet

CLI to transform between JSON, EDN, YAML and Transit using Clojure
Clojure
584
star
2

carve

Remove unused Clojure vars
Clojure
275
star
3

grasp

Grep Clojure code using clojure.spec regexes
Clojure
233
star
4

deps.clj

A faithful port of the clojure CLI bash script to Clojure
Clojure
225
star
5

speculative

Unofficial community-driven specs for clojure.core
Clojure
185
star
6

edamame

Configurable EDN/Clojure parser with location metadata
Clojure
155
star
7

clojure-rust-graalvm

An example of Clojure program calling a Rust library, all combined into one executable using GraalVM.
Rust
120
star
8

re-find

Find functions by matching specs
Clojure
118
star
9

quickdoc

Quick and minimal API doc generation for Clojure
Clojure
116
star
10

bebo

Run Clojure scripts on deno
Clojure
98
star
11

flycheck-clj-kondo

Emacs integration for clj-kondo via flycheck
Emacs Lisp
84
star
12

rewrite-edn

Utility lib on top of rewrite-clj with common operations to update EDN while preserving whitespace and comments.
Clojure
76
star
13

clj2el

Transpile Clojure to Emacs Lisp!
Clojure
63
star
14

glam

A cross-platform package manager.
Clojure
62
star
15

api-diff

Print API diffs between library versions
Clojure
59
star
16

deflet

Make let-expressions REPL-friendly!
Clojure
57
star
17

cljtree-graalvm

Tree version in Clojure built with GraalVM
Clojure
53
star
18

respeced

Testing library for clojure.spec fdefs
Clojure
52
star
19

jayfu

Jayfu is a tutorial on how to create a Clojure CLI with GraalVM native-image and SCI.
Clojure
52
star
20

dynaload

The dynaload logic from clojure.spec.alpha as a library
Clojure
52
star
21

lein2deps

Lein project.clj to deps.edn converter
Clojure
50
star
22

blog

HTML
49
star
23

plsci

PostgreSQL procedural language handler for Clojure via SCI
Rust
48
star
24

advent-of-cljc

Cross platform Clojure Advent of Code solutions
Clojure
44
star
25

boot-bundle

boot-bundle: managed dependencies for boot, the clojure build tool
Clojure
43
star
26

deps-infer

Infer mvn deps from sources
Clojure
39
star
27

puget-cli

A CLI version of puget
Shell
37
star
28

specter-cli

A native Specter CLI, compiled with GraalVM native-image and executed by SCI.
Clojure
33
star
29

draggable-button-in-reagent

Very simple example of a draggable button in Reagent
Clojure
31
star
30

spartan.spec

A spartan version of clojure.spec compatible with babashka
Clojure
30
star
31

lein-new-liberagent

leiningen template for apps that use reagent and liberator
Clojure
29
star
32

re-find.web

Web version of re-find
Clojure
25
star
33

nbb-action-example

An example of writing a Github action with nbb
Clojure
24
star
34

lein2boot

The goal of this exercise is to convert a leiningen project to boot and have exactly the same workflow.
Clojure
24
star
35

gh-release-artifact

Upload artifacts to Github releases idempotently
Clojure
24
star
36

balcony

Should I water my balcony?
Clojure
23
star
37

generate-podcast

A babashka script to create a podcast from a local directory with mp3 files
Clojure
22
star
38

tools

Tools
Clojure
19
star
39

fly_io_clojure

A fly.io example for Clojure
Clojure
17
star
40

refl

Clean up generated reflection configs for GraalVM native-image compiled Clojure programs
Clojure
17
star
41

analyze-reify

Analyze occurrences of reify in Clojure code. Implemented using tree-sitter-clojure and Rust.
Rust
17
star
42

advent-of-babashka

Advent of Code using babashka and nbb
Clojure
16
star
43

aoc2017

Advent of Code 2017
Clojure
15
star
44

lein-new-wrom

Webjars + Ring + Om leiningen template
Clojure
15
star
45

clj-reflector-graal-java11-fix

A fix for an issue with clojure.lang.Reflector in GraalVM native-image JDK11.
Clojure
15
star
46

clj.el

Clojure-like macros and functions in elisp
Emacs Lisp
13
star
47

cljs-showcase

Clojure
13
star
48

balcony-hs

Should I water my balcony?
Haskell
13
star
49

babashka-docker-action-example

Dockerfile
12
star
50

who-follows-me

Check who follows you, but you're not following back and vice versa. https://twitter.michielborkent.nl
Clojure
12
star
51

trickle-playground

A Truffle Clojure Interpreter (playground)
Java
12
star
52

finitize

Limit and realize possibly infinite seqs
Clojure
12
star
53

nrepl-server

Proof of concept nREPL server
Clojure
10
star
54

full-stack-clojure-han-okt-2015

Talk about developing full stack Clojure applications at HAN University of Applied Sciences
Clojure
10
star
55

clojurecursus

Introductiecursus Functioneel Programmeren met Clojure
CSS
10
star
56

missing.test.assertions

A library that detects missing test assertions in clojure.test tests
Clojure
9
star
57

deps.add-lib

Clojure 1.12's add-lib feature for leiningen and/or other environments without a specific version of the clojure CLI
Clojure
8
star
58

figwheel-keep-om-turning

Code for blog post at http://blog.michielborkent.nl/2014/09/25/figwheel-keep-Om-turning/
Clojure
8
star
59

cljtree-planck

A ClojureScript version of `tree` in Planck
Shell
6
star
60

bun-squint-loader

JavaScript
6
star
61

simple-cljs-examples

Curated list of ClojureScript sample applications suited for those starting with ClojureScript
6
star
62

graal.locking

A workaround for CLJ-1472 as a library
Clojure
6
star
63

tictactoe

tictactoe (clojure)
Clojure
5
star
64

bb-cherry-example

A web app showing real time JS compilation with babashka and cherry
Clojure
5
star
65

immutable-webapp

Immutable Webapp!
HTML
5
star
66

spartan.test

A spartan test framework compatible with babashka.
Clojure
5
star
67

speculative-kaocha-plugin

speculative kaocha plugin
Clojure
5
star
68

aoc2015_day7

Solution of Advent of Code Day 7 using clojure.spec
Clojure
4
star
69

oredev2014

Slides and code for Øredev 2014
Clojure
4
star
70

tictactoe-cljs

Tictactoe in Clojurescript and Om
Clojure
4
star
71

cherry-action-example

Github action implemented with cherry
Clojure
4
star
72

homebrew-brew

Homebrew formulas
Shell
4
star
73

datalevin-native

Clojure
4
star
74

sci-wallpaper-downloader

A port of @yogthos's wallpaper downloader to the Small Clojure Interpreter on NodeJS
Clojure
4
star
75

domcode-cljs-react

Slides and code for presentation at the DomCode meetup
Clojure
4
star
76

clj-jdbc

A hypothetical Clojure command tool focusing around SQL interaction via JDBC
Clojure
4
star
77

sci-birch

tree CLI using sci, ported from lambdaisland's birch
Clojure
3
star
78

clj-native-sound-demo

A demo of using the Java sound API with GraalVM native-image
Clojure
3
star
79

bb-php-guestbook

A guestbook using babashka and PHP
Clojure
2
star
80

michielborkent.nl

Home page sources
Clojure
2
star
81

clj-kondo-configurator

CLI tool to merge clj-kondo configurations.
Clojure
2
star
82

boot.bundle.edn

My boot.bundle.edn file
Clojure
2
star
83

my-aob

Clojure
2
star
84

FP-AMS-ClojureScript-talk

Slides and code for talk at FP AMS about Clojurescript
Clojure
2
star
85

react-amsterdam

Talk for React-Amsterdam, February 12th 2015
Clojure
2
star
86

pprint

Clojure
2
star
87

sytac-core-async

Slides and code for presentation at Sytac Devjam
Clojure
2
star
88

SnakeYAML

Temporary fork of SnakeYAML
Java
1
star
89

leiningen.org

Leiningen's web site
Clojure
1
star
90

itunes2dropbox

Share the current playing song or selected songs from iTunes to your Dropbox public folder.
AppleScript
1
star
91

try_git

1
star
92

clj-1472-repro

A repro of CLJ-1472
Clojure
1
star
93

cljs-macro

Example of usage of a macro in ClojureScript.
Clojure
1
star
94

squint-bun-cloudflare

JavaScript
1
star
95

aoc2016

Advent of Clojure 2016
Clojure
1
star
96

fp-hu-may-2016

Talk about Functional Programming at Hogeschool Utrecht, May 2016
Clojure
1
star
97

Clojure-FinalAssignment

Quiz
Clojure
1
star
98

ns-parser

Helper library for parsing ns forms in combination with edamame and rewrite-clj
Clojure
1
star
99

test-repo

Repo to test Github features
Clojure
1
star
100

clj-kondo.web

playground for clj-kondo
Clojure
1
star