my website
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

blog about 75% done

chfour c312c875 77cf5ed4

+103 -12
+1
.gitignore
··· 1 1 result 2 2 src/fonts 3 + src/blog/**/index.html
+3
README.md
··· 7 7 8 8 [this](https://github.com/chfour/nixos/blob/main/machines/fovps/services/caddy/default.nix) 9 9 is the other part of the code that makes this run and it is Cursed because of caching 10 + 11 + run the following to serve everything locally: 12 + `nix run nixpkgs#caddy -- file-server -l 0.0.0.0:8000 -a -r "$(nix build .#website.out --no-link --print-out-paths)/var/www"`
+28
buildblog.sh
··· 1 + #!/usr/bin/env sh 2 + 3 + template_start='<!--BEGIN TEMPLATE-->' 4 + template_end='<!--END TEMPLATE-->' 5 + 6 + [ -n "$1" ] && cd "$1" 7 + 8 + sed "/${template_start}/q" ./index_template.html > ./index.html 9 + 10 + # this... thing turns the template in the html into a json string with jq string interpolation, to be passed back into jq 11 + # thankfully this only has to be done once. cursedd 12 + template="$(sed "/\s*${template_start}/,/\s*${template_end}/!d;//d" ./index_template.html | \ 13 + jq -Rs '"\"" + (gsub("(?<s>^|}})(?<p>.+?)(?<e>{{|$)"; "\(.s + (.p|@json|trimstr("\"")) + .e)"; "m") | rtrim | gsub("{{(?<p>.+?)}}"; "\\(\(.p))"; "m")) + "\""' -r)" 14 + 15 + find . -name content.djot -print0 | sort -r | while read -r -d '' post; do 16 + post="${post%/*}" 17 + echo -n "${post} " 18 + jq -r '.title' "${post}/meta.json" 19 + jq -r --arg path "${post#./*/*/}" "${template}" "${post}/meta.json" >> ./index.html 20 + pandoc -f djot -t html5 \ 21 + --mathml \ 22 + --highlight-style=kate \ 23 + --standalone \ 24 + --metadata-file="${post}/meta.json" \ 25 + "${post}/content.djot" -o "${post}/index.html" 26 + done 27 + 28 + sed -n "/${template_end}/,\$p" ./index_template.html >> ./index.html
+17 -5
flake.nix
··· 79 79 ''; 80 80 }; 81 81 82 + packages.buildblog = pkgs.writeShellApplication { 83 + name = "buildblog"; 84 + runtimeInputs = with pkgs; [ jq pandoc ]; 85 + text = builtins.readFile ./buildblog.sh; # eh? 86 + }; 87 + 82 88 packages.website = pkgs.stdenvNoCC.mkDerivation { 83 89 name = "chfour-website"; 84 90 85 91 src = ./src; 86 92 87 - phases = [ "installPhase" ]; 93 + buildPhase = '' 94 + runHook preBuild 95 + 96 + ln -sf ${selfPkgs.website-fonts} ./fonts 97 + ${selfPkgs.buildblog}/bin/buildblog blog/ 98 + rm blog/index_template.html 99 + 100 + runHook postBuild 101 + ''; 88 102 89 103 installPhase = '' 90 104 runHook preInstall 91 105 92 - mkdir -p $out 93 - 94 - cp -r $src/* $out/ 95 - ln -sf ${selfPkgs.website-fonts} $out/fonts 106 + mkdir -p $out/var/www 107 + cp -r * $out/var/www 96 108 97 109 runHook postInstall 98 110 '';
+12
src/blog/2025-09-14-test/content.djot
··· 1 + # test post 2 + 3 + helloooo *oooo* _oooh_ 4 + 5 + ``` c 6 + #include <stdio.h> 7 + 8 + int main() { 9 + printf("balls\n"); 10 + return 0; 11 + } 12 + ```
+5
src/blog/2025-09-14-test/meta.json
··· 1 + { 2 + "title": "me and my stupid chud blog ssg child", 3 + "date": "2025-09-14", 4 + "tags": ["test", "test2"] 5 + }
+24
src/blog/index_template.html
··· 1 + <!DOCTYPE html> 2 + <html lang="en"> 3 + <head> 4 + <meta charset="UTF-8"> 5 + <meta name="viewport" content="width=device-width, initial-scale=1.0"> 6 + <meta name="generator" content="jq and a shell script"> 7 + <title>blog index</title> 8 + <link rel="stylesheet" href="../style.css"> 9 + <style> 10 + a { 11 + text-decoration: none; 12 + } 13 + </style> 14 + </head> 15 + <body> 16 + <ul> 17 + <!--BEGIN TEMPLATE--> 18 + <li><article> 19 + <a href="{{$path}}/">{{.title | @html}}</a> {{.tags | map("<span class=\"tag\" data-tag=\"\(.)\">\(.)</span>") | join(" ")}} 20 + </article></li> 21 + <!--END TEMPLATE--> 22 + </ul> 23 + </body> 24 + </html>
+13 -7
src/style.css
··· 20 20 21 21 :root { 22 22 color-scheme: light dark; 23 - --color-fg: #f2f2f2; 24 - --color-bg: #000; 23 + --color-fg: #000; 24 + --color-bg: #f2f2f2; 25 25 --color-link: #7d29e2; 26 26 --color-link-visited: #a800ad; 27 27 } ··· 44 44 line-height: 1.5; 45 45 font-weight: 500; 46 46 47 - margin: 0; 48 - } 49 - 50 - article { 51 47 margin: 3rem; 52 48 } 53 49 54 50 a { color: var(--color-link); } 55 51 a:visited { color: var(--color-link-visited); } 56 - 57 52 58 53 img { display: block; } 59 54 ··· 66 61 content: ' / '; 67 62 padding-inline: 0.25em; 68 63 } 64 + 65 + .tag { 66 + /* intentional swap */ 67 + background-color: var(--color-fg); 68 + color: var(--color-bg); 69 + font-size: 0.9em; 70 + border-radius: 0.4em; 71 + padding: 0.2em 0.4em; 72 + } 73 + 74 + .tag[data-tag="test"] { background-color: rgb(255, 112, 112); color: black; }