my website
0
fork

Configure Feed

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

added actual post page templates with code syntax highlighting

chfour 1d11a89e 4ad7bf12

+133 -18
+1
.gitignore
··· 1 1 result 2 2 src/fonts 3 3 src/blog/**/index.html 4 + src/blog/highlighting.css
+29 -7
buildblog.sh
··· 1 1 #!/usr/bin/env sh 2 2 3 + index_template='template_index.html' 4 + page_template='template_page.html' 3 5 template_start='<!--BEGIN TEMPLATE-->' 4 6 template_end='<!--END TEMPLATE-->' 5 7 6 - [ -n "$1" ] && cd "$1" 8 + [ -n "${1}" ] && cd "${1}" 9 + ! [ -e "$index_template" ] && echo "${0}: error: ${1%/}/${index_template} does not exist" >&2 && exit 1 10 + ! [ -e "$page_template" ] && echo "${0}: error: ${1%/}/${page_template} does not exist" >&2 && exit 1 7 11 8 - sed "/${template_start}/q" ./index_template.html > ./index.html 12 + # generate the code syntax highlighting css 13 + # unfortunately pandoc did not like --template=<(echo ...) 14 + # shellcheck disable=SC2016 15 + echo '$highlighting-css$' > ./highlighting.css 16 + # time to prank pandoc epic style 17 + echo $'``` c\n```' | pandoc -f djot -t html5 \ 18 + --template=./highlighting.css -o ./highlighting.css \ 19 + --highlight-style=tango # to be replaced, probably 20 + 21 + # ...because of this. and because it looks eh 22 + cat >> ./highlighting.css <<EOF 23 + .sourceCode { color: black; } 24 + EOF 25 + 26 + sed "/${template_start}/q" "${index_template}" > ./index.html 9 27 10 28 # this... thing turns the template in the html into a json string with jq string interpolation, to be passed back into jq 11 29 # thankfully this only has to be done once. cursedd 12 - template="$(sed "/\s*${template_start}/,/\s*${template_end}/!d;//d" ./index_template.html | \ 30 + template="$(sed "/\s*${template_start}/,/\s*${template_end}/!d;//d" "${index_template}" | \ 13 31 jq -Rs '"\"" + (gsub("(?<s>^|}})(?<p>.+?)(?<e>{{|$)"; "\(.s + (.p|@json|trimstr("\"")) + .e)"; "m") | rtrim | gsub("{{(?<p>.+?)}}"; "\\(\(.p))"; "m")) + "\""' -r)" 14 32 15 33 find . -name content.djot -print0 | sort -r -z | while read -r -d '' post; do 16 34 post="${post%/*}" 17 35 echo -n "${post} " 18 - jq -r '.title' "${post}/meta.json" 36 + slashesinpath="${post//[^\/]}" # delete everything that isnt a slash 37 + slashesinpath="${#slashesinpath}" # count whats left (count slashes in $post) 38 + backtoblogroot="$(for ((i=0; i < slashesinpath; i++)); do echo -n '../'; done)" 39 + backtoblogroot="${backtoblogroot%/}" 40 + jq '.title' "${post}/meta.json" 19 41 jq -r --arg path "${post#./*/*/}" "${template}" "${post}/meta.json" >> ./index.html 20 42 pandoc -f djot -t html5 \ 21 43 --mathml \ 22 - --highlight-style=kate \ 23 - --standalone \ 44 + --template="${page_template}" \ 45 + --variable="backtoblogroot=${backtoblogroot}" \ 24 46 --metadata-file="${post}/meta.json" \ 25 47 "${post}/content.djot" -o "${post}/index.html" 26 48 done 27 49 28 - sed -n "/${template_end}/,\$p" ./index_template.html >> ./index.html 50 + sed -n "/${template_end}/,\$p" "${index_template}" >> ./index.html
+1 -1
flake.nix
··· 95 95 96 96 ln -sf ${selfPkgs.website-fonts} ./fonts 97 97 ${selfPkgs.buildblog}/bin/buildblog blog/ 98 - rm blog/index_template.html 98 + rm blog/template_{index,page}.html 99 99 100 100 runHook postBuild 101 101 '';
+36 -8
src/blog/2025-09-14-test/content.djot
··· 1 - # test post 2 - 3 1 helloooo *oooo* _oooh_ 4 2 5 - ``` c 6 - #include <stdio.h> 3 + heres some math lmao $`\frac{2}{3} * \frac{3}{2}` 7 4 8 - int main() { 9 - printf("balls\n"); 10 - return 0; 11 - } 5 + and heres some blurb the fitnessgram pacer test yadda yadda yadda 6 + ooooo aaaaa did you kn EU07.EXE EU07 (cmake), 00578a3 (committed at 2024-06-13 01:29:12 +0200) 7 + Failed to open file "eu07.ini" Bad init: failed to create glfw window 8 + Did you know it's really easy to hack your 3DS? Anyone can do it! 9 + 10 + the gnome color palette is really nice i should use it here tbh. look ma i am design 11 + 12 + I am Steve Jobs? I am Steve Jobs. 13 + 14 + ``` c 15 + // a more realistic code example 16 + for (i = 0; i < samplecount; i++) { 17 + int8_t s = samples[i]; 18 + 19 + // correlation: multiply by sine and cosine f=1200Hz and 2200Hz 20 + // 1200.0 * SPS = samplerate 21 + // & (1<<int(SPS/8+1) - 1) 22 + int_mark_i[i & 0b111] = sin(TWOPI * i * (1200.0 / (1200.0 * SPS))) * s; 23 + int_mark_q[i & 0b111] = cos(TWOPI * i * (1200.0 / (1200.0 * SPS))) * s; 24 + int_space_i[i & 0b111] = sin(TWOPI * i * (2200.0 / (1200.0 * SPS))) * s; 25 + int_space_q[i & 0b111] = cos(TWOPI * i * (2200.0 / (1200.0 * SPS))) * s; 26 + // integration 27 + float sum_mark_i = 0; 28 + float sum_mark_q = 0; 29 + float sum_space_i = 0; 30 + float sum_space_q = 0; 31 + for (uint8_t j = 0; j < SPS; j++) { 32 + sum_mark_i += int_mark_i[j]; 33 + sum_mark_q += int_mark_q[j]; 34 + sum_space_i += int_space_i[j]; 35 + sum_space_q += int_space_q[j]; 36 + } 37 + float sum_mark = sum_mark_i*sum_mark_i + sum_mark_q*sum_mark_q; 38 + float sum_space = sum_space_i*sum_space_i + sum_space_q*sum_space_q; 39 + /* ... */ 12 40 ```
+1
src/blog/2025-09-14-test/meta.json
··· 1 1 { 2 2 "title": "me and my stupid chud blog ssg child", 3 + "lang": "en", 3 4 "date": "2025-09-14", 4 5 "tags": ["test", "test2"] 5 6 }
src/blog/index_template.html src/blog/template_index.html
+55
src/blog/template_page.html
··· 1 + <!DOCTYPE html> 2 + <html lang="$lang$"> 3 + <head> 4 + <meta charset="UTF-8"> 5 + <meta name="viewport" content="width=device-width, initial-scale=1.0"> 6 + <meta name="generator" content="pandoc and a shell script"> 7 + <title>$if(title-prefix)$$title-prefix$ &ndash; $endif$$pagetitle$</title> 8 + $if(highlighting-css)$ 9 + <link rel="stylesheet" href="$backtoblogroot$/highlighting.css"> 10 + $endif$ 11 + <link rel="stylesheet" href="$backtoblogroot$/../style.css"> 12 + $for(author-meta)$ 13 + <meta name="author" content="$author-meta$" /> 14 + $endfor$ 15 + $if(keywords)$ 16 + <meta name="keywords" content="$for(keywords)$$keywords$$sep$, $endfor$" /> 17 + $endif$ 18 + $if(description-meta)$ 19 + <meta name="description" content="$description-meta$" /> 20 + $endif$ 21 + $for(css)$ 22 + <link rel="stylesheet" href="$css$" /> 23 + $endfor$ 24 + $for(header-includes)$ 25 + $header-includes$ 26 + $endfor$ 27 + </head> 28 + <body> 29 + <article> 30 + $for(include-before)$ 31 + $include-before$ 32 + $endfor$ 33 + $if(title)$ 34 + <header id="title-block-header"> 35 + <h1 class="title">$title$</h1> 36 + <p> 37 + $if(date-meta)$ 38 + <time datetime="$date-meta$">$date-meta$</time> 39 + $endif$ 40 + $for(tags)$<span class="tag" data-tag="$tags$">$tags$</span> $endfor$ 41 + </p> 42 + $if(subtitle)$ 43 + <p class="subtitle">$subtitle$</p> 44 + $endif$ 45 + </header> 46 + $endif$ 47 + <main> 48 + $body$ 49 + </main> 50 + $for(include-after)$ 51 + $include-after$ 52 + $endfor$ 53 + </article> 54 + </body> 55 + </html>
+10 -2
src/style.css
··· 67 67 background-color: var(--color-fg); 68 68 color: var(--color-bg); 69 69 font-size: 0.9em; 70 - border-radius: 0.4em; 71 - padding: 0.2em 0.4em; 70 + border-radius: 0.3rem; 71 + padding: 0.2rem 0.4rem; 72 72 } 73 73 74 74 .tag[data-tag="test"] { background-color: rgb(255, 112, 112); color: black; } 75 + 76 + pre { 77 + padding: 1rem; 78 + font-size: 1.1em; 79 + } 80 + :not(.sourceCode) > pre:has(code), div.sourceCode { 81 + border-radius: 1rem; 82 + }