Snippets
SNP 001–153
Loosely organized collection of code snippets. Maybe you'll find something useful here.
Showing 20 of 153 snippets
-
SNP153
Find the slowest pages in a Stati 2 build
The metrics count the templates each page really rendered now, and the cache manifest names them.
11 lines of sh in 2 blocks, 18 lines of explanation.
#64A -
SNP152
Fail CI when a Stati 2 build falls back
A broken template still exits with 0, and a misspelled include leaves nothing in the page to find. The build log has all of it.
16 lines of sh in 1 block, 18 lines of explanation.
#B21 -
SNP151
Pick a layout per page in Stati 2
Layout names are looked up from the page's folder now, the same way as includes. And a typo finally gets a warning.
18 lines of yaml, text and eta in 4 blocks, 19 lines of explanation.
#594 -
SNP150
Template helpers in Stati 2
Stati 1's filters are helpers now, with a config key of their own. And their parameters can have real types.
20 lines of ts and eta in 2 blocks, 15 lines of explanation.
#A31 -
SNP149
Includes with props in Stati 2
A card component, included by its path. The guard Stati 1 components needed on their first line can go.
11 lines of eta in 4 blocks, 19 lines of explanation with 3 notes.
#2B7 -
SNP148
A page for every tag in Stati
One [tag].md template, URLs from Stati's slugify, and links that match them.
21 lines of yaml and eta in 4 blocks, 18 lines of explanation with 4 notes.
#415 -
SNP147
Paginate a listing in Stati
One line of front matter for numbered pages, and a pager built from stati.pagination.
31 lines of yaml and eta in 2 blocks, 15 lines of explanation with 5 notes.
#693 -
SNP146
Design your own link preview card in Stati
An og.eta that Satori can draw, a font of your own, and the rules it holds you to.
12 lines of sh, ts and eta in 3 blocks, 14 lines of explanation with 4 notes.
#924 -
SNP145
List a section's posts anywhere in Stati
The newest posts on the home page from one line of front matter, and prev/next links without a hook.
23 lines of yaml and eta in 3 blocks, 15 lines of explanation with 4 notes.
#1B3 -
SNP144
Images in Stati Markdown and layouts
Where image paths point, what Stati adds to the images, and stati.image() for covers.
7 lines of md, eta and ts in 3 blocks, 20 lines of explanation with 4 notes.
#A34 -
SNP143
Trusted certificates for localhost with mkcert
HTTPS on your dev server without the browser warning, in three commands.
8 lines of sh and js in 2 blocks, 10 lines of explanation.
#46B -
SNP142
Wait a second in GDScript
Pause a function without blocking the game, the Godot 4 way.
6 lines of gd in 3 blocks, 6 lines of explanation.
#5B3 -
SNP141
Fail CI when a Stati build falls back
A broken config, layout or partial still exits with 0. Two greps catch them.
15 lines of sh in 1 block, 16 lines of explanation with 3 notes.
#241 -
SNP140
Create a database user in MariaDB
One user per application, with only the rights it needs.
6 lines of sql in 2 blocks, 6 lines of explanation.
#925 -
SNP139
Tail CloudWatch logs
Watch a Lambda's logs live, from the terminal, like tail -f.
3 lines of sh in 3 blocks, 5 lines of explanation.
#369 -
SNP138
Resize images in bulk with ImageMagick
Shrink a folder of photos for the web in one command.
3 lines of sh in 2 blocks, 10 lines of explanation with 4 notes.
#13B -
SNP137
Read and write JSON in Python
The json module, with the two options that make the output readable.
11 lines of py in 1 block, 5 lines of explanation.
#694 -
SNP136
Open WSL folders in Explorer and the other way around
Moving between the Linux and the Windows side without copying files.
3 lines of sh in 3 blocks, 9 lines of explanation.
#A51 -
SNP135
Different config for dev and production in Stati
getEnv() knows which command is running. NODE_ENV doesn't.
16 lines of ts in 1 block, 12 lines of explanation with 4 notes.
#529 -
SNP134
LLM prompt for generating test cases
Get the edge cases you didn't think of, in your own test framework.
18 lines of md in 1 block, 2 lines of explanation.
#3B5
No snippets match this filter.