Sweeping readability imrpovements

This commit is contained in:
Mrrp 2025-01-01 00:26:10 -08:00
parent 5eb48fb4b6
commit ebaff6dea0
13 changed files with 1678 additions and 114 deletions

View file

@ -40,7 +40,12 @@ echo " \"posts\": ["
# and output it as JSON.
extract_front_matter() {
local data="$1"
local front_matter=$(echo "$data" | sed -n '/^---/,/^---/p')
# Remove everything after the second '---'
# make sure everything between the first and second '---' is the front matter
# use awk
local front_matter=$(echo "$data" | awk '/---/ && !f {f=1; next} f; /---/ {exit}')
echo "$front_matter" | sed '1d;$d' | sed 's/^/ "/' | sed 's/: /": "/' | sed 's/$/"/' | tr '\n' ',' | sed 's/,$//' | sed 's/"tags": "\[\(.*\)\]"/"tags": \[\1\]/g' | sed "s/'/\"/g"
}