Initial Setup
Tooling:
nix/direnv to ensure dependencies are present
jinja-based templating to avoid duplication of common sections of pages
(header and footer, primarily)
auto-rebuilding server for rapid iteration
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/build/
|
||||
/.direnv/
|
||||
10
base.html
Normal file
10
base.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>{% block title %}{% endblock title %}</title>
|
||||
</head>
|
||||
<body>
|
||||
<nav></nav>
|
||||
{% block main %}{% endblock main %}
|
||||
</body>
|
||||
</html>
|
||||
39
flake.lock
generated
Normal file
39
flake.lock
generated
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1708118438,
|
||||
"narHash": "sha256-kk9/0nuVgA220FcqH/D2xaN6uGyHp/zoxPNUmPCMmEE=",
|
||||
"path": "/nix/store/bg5fbkfa5x53clcjf4p5p92k1l3w8x38-source",
|
||||
"rev": "5863c27340ba4de8f83e7e3c023b9599c3cb3c80",
|
||||
"type": "path"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs",
|
||||
"systems": "systems"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "systems",
|
||||
"type": "indirect"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
25
flake.nix
Normal file
25
flake.nix
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
outputs = {
|
||||
nixpkgs,
|
||||
systems,
|
||||
self,
|
||||
}: let
|
||||
eachSystem = f:
|
||||
nixpkgs.lib.genAttrs (import systems) (system:
|
||||
f {
|
||||
inherit system;
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
});
|
||||
in {
|
||||
devShells = eachSystem ({pkgs, ...}: {
|
||||
default = pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
just
|
||||
simple-http-server
|
||||
watchexec
|
||||
(python3.withPackages (ps: with ps; [jinja2]))
|
||||
];
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
||||
21
justfile
Normal file
21
justfile
Normal file
@@ -0,0 +1,21 @@
|
||||
dir:
|
||||
mkdir -p build
|
||||
|
||||
template: dir
|
||||
#!/usr/bin/env python3
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
from glob import glob
|
||||
env = Environment(loader=FileSystemLoader('.'))
|
||||
for file in glob("*", root_dir="pages/"):
|
||||
with open(f"build/{file}", "w") as out:
|
||||
out.write(env.get_template(f"pages/{file}").render())
|
||||
|
||||
build: template
|
||||
cp -r static/ build/
|
||||
|
||||
serve: build
|
||||
simple-http-server --index --nocache build/
|
||||
|
||||
watch:
|
||||
watchexec --restart -- just serve
|
||||
|
||||
5
pages/index.html
Normal file
5
pages/index.html
Normal file
@@ -0,0 +1,5 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Home{% endblock %}
|
||||
{% block main %}
|
||||
<h1>Some body content</h1>
|
||||
{% endblock %}
|
||||
0
static/.gitkeep
Normal file
0
static/.gitkeep
Normal file
Reference in New Issue
Block a user