diff --git a/.gitignore b/.gitignore index cadf017..b0b3233 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ result src/fonts src/blog/**/index.html +src/blog/highlighting.css diff --git a/buildblog.sh b/buildblog.sh index 3abc691..b584c49 100755 --- a/buildblog.sh +++ b/buildblog.sh @@ -1,28 +1,50 @@ #!/usr/bin/env sh +index_template='template_index.html' +page_template='template_page.html' template_start='' template_end='' -[ -n "$1" ] && cd "$1" +[ -n "${1}" ] && cd "${1}" +! [ -e "$index_template" ] && echo "${0}: error: ${1%/}/${index_template} does not exist" >&2 && exit 1 +! [ -e "$page_template" ] && echo "${0}: error: ${1%/}/${page_template} does not exist" >&2 && exit 1 -sed "/${template_start}/q" ./index_template.html > ./index.html +# generate the code syntax highlighting css +# unfortunately pandoc did not like --template=<(echo ...) +# shellcheck disable=SC2016 +echo '$highlighting-css$' > ./highlighting.css +# time to prank pandoc epic style +echo $'``` c\n```' | pandoc -f djot -t html5 \ + --template=./highlighting.css -o ./highlighting.css \ + --highlight-style=tango # to be replaced, probably + +# ...because of this. and because it looks eh +cat >> ./highlighting.css < ./index.html # this... thing turns the template in the html into a json string with jq string interpolation, to be passed back into jq # thankfully this only has to be done once. cursedd -template="$(sed "/\s*${template_start}/,/\s*${template_end}/!d;//d" ./index_template.html | \ +template="$(sed "/\s*${template_start}/,/\s*${template_end}/!d;//d" "${index_template}" | \ jq -Rs '"\"" + (gsub("(?^|}})(?

.+?)(?{{|$)"; "\(.s + (.p|@json|trimstr("\"")) + .e)"; "m") | rtrim | gsub("{{(?

.+?)}}"; "\\(\(.p))"; "m")) + "\""' -r)" find . -name content.djot -print0 | sort -r -z | while read -r -d '' post; do post="${post%/*}" echo -n "${post} " - jq -r '.title' "${post}/meta.json" + slashesinpath="${post//[^\/]}" # delete everything that isnt a slash + slashesinpath="${#slashesinpath}" # count whats left (count slashes in $post) + backtoblogroot="$(for ((i=0; i < slashesinpath; i++)); do echo -n '../'; done)" + backtoblogroot="${backtoblogroot%/}" + jq '.title' "${post}/meta.json" jq -r --arg path "${post#./*/*/}" "${template}" "${post}/meta.json" >> ./index.html pandoc -f djot -t html5 \ --mathml \ - --highlight-style=kate \ - --standalone \ + --template="${page_template}" \ + --variable="backtoblogroot=${backtoblogroot}" \ --metadata-file="${post}/meta.json" \ "${post}/content.djot" -o "${post}/index.html" done -sed -n "/${template_end}/,\$p" ./index_template.html >> ./index.html +sed -n "/${template_end}/,\$p" "${index_template}" >> ./index.html diff --git a/flake.nix b/flake.nix index 605640a..812ec25 100644 --- a/flake.nix +++ b/flake.nix @@ -95,7 +95,7 @@ ln -sf ${selfPkgs.website-fonts} ./fonts ${selfPkgs.buildblog}/bin/buildblog blog/ - rm blog/index_template.html + rm blog/template_{index,page}.html runHook postBuild ''; diff --git a/src/blog/2025-09-14-test/content.djot b/src/blog/2025-09-14-test/content.djot index 12831d5..9241595 100644 --- a/src/blog/2025-09-14-test/content.djot +++ b/src/blog/2025-09-14-test/content.djot @@ -1,12 +1,40 @@ -# test post - helloooo *oooo* _oooh_ -``` c -#include +heres some math lmao $`\frac{2}{3} * \frac{3}{2}` + +and heres some blurb the fitnessgram pacer test yadda yadda yadda +ooooo aaaaa did you kn EU07.EXE EU07 (cmake), 00578a3 (committed at 2024-06-13 01:29:12 +0200) +Failed to open file "eu07.ini" Bad init: failed to create glfw window +Did you know it's really easy to hack your 3DS? Anyone can do it! -int main() { - printf("balls\n"); - return 0; -} +the gnome color palette is really nice i should use it here tbh. look ma i am design + +I am Steve Jobs? I am Steve Jobs. + +``` c +// a more realistic code example +for (i = 0; i < samplecount; i++) { + int8_t s = samples[i]; + + // correlation: multiply by sine and cosine f=1200Hz and 2200Hz + // 1200.0 * SPS = samplerate + // & (1< + + + + + + $if(title-prefix)$$title-prefix$ – $endif$$pagetitle$ +$if(highlighting-css)$ + +$endif$ + +$for(author-meta)$ + +$endfor$ +$if(keywords)$ + +$endif$ +$if(description-meta)$ + +$endif$ +$for(css)$ + +$endfor$ +$for(header-includes)$ + $header-includes$ +$endfor$ + + +

+$for(include-before)$ +$include-before$ +$endfor$ +$if(title)$ +
+

$title$

+

+$if(date-meta)$ + +$endif$ + $for(tags)$$tags$ $endfor$ +

+$if(subtitle)$ +

$subtitle$

+$endif$ +
+$endif$ +
+$body$ +
+$for(include-after)$ +$include-after$ +$endfor$ +
+ + diff --git a/src/style.css b/src/style.css index 834b968..4d22753 100644 --- a/src/style.css +++ b/src/style.css @@ -67,8 +67,16 @@ img { display: block; } background-color: var(--color-fg); color: var(--color-bg); font-size: 0.9em; - border-radius: 0.4em; - padding: 0.2em 0.4em; + border-radius: 0.3rem; + padding: 0.2rem 0.4rem; } .tag[data-tag="test"] { background-color: rgb(255, 112, 112); color: black; } + +pre { + padding: 1rem; + font-size: 1.1em; +} +:not(.sourceCode) > pre:has(code), div.sourceCode { + border-radius: 1rem; +}