A "coreutil" static site generator
2
fork

Configure Feed

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

fix: read body before header/footer

+17 -9
+9 -7
cuss
··· 6 6 _cmark() { cmark -t html "$@"; } 7 7 _envsb() { envsubst; } 8 8 _csplit() { csplit -b '%02d.split' -s "$@" 2>/dev/null; } 9 - _output() { printf '%s' "$*"; } 10 9 _find() { d=$1; shift; find "$d" -not -path './.*' "$@"; } 11 10 12 11 # Read file, substituting values of env vars. ··· 25 24 # read text first 26 25 txt=$(cat "$src") 27 26 28 - _output "$txt" | _csplit --suppress-matched \ 27 + echo "$txt" | _csplit --suppress-matched \ 29 28 - \ 30 29 "%^---%" \ 31 30 "/^---/" ··· 46 45 rm "$sf" 47 46 else 48 47 # no split (meaning, no front matter) 49 - _output "$txt" | readfile 48 + echo "$txt" | readfile 50 49 fi 51 50 } 52 51 ··· 99 98 cmd_generate() { 100 99 header= 101 100 footer= 101 + body=$(mktemp) 102 + 103 + readfm "${1:--}" >"${body}" 102 104 103 105 if sf="${CUSS_HEADER_FILE:-}" && [ -f "$sf" ]; then 104 106 header=$(readfile "$sf") ··· 108 110 footer=$(readfile "$sf") 109 111 fi 110 112 111 - body=$(readfm "${1:--}" | convertmd -) 113 + [ "${header}" ] && echo "${header}" 114 + [ -f "${body}" ] && convertmd "${body}" 115 + [ "${footer}" ] && echo "${footer}" 112 116 113 - _output "${header}" 114 - _output "${body}" 115 - _output "${footer}" 117 + rm -f "${body}" 116 118 } 117 119 118 120 # Command: make
+8 -2
tests/make.bats
··· 48 48 test "$status" = 0 49 49 50 50 test -f index.html 51 - test "$index_html" = "$(cat index.html)" 51 + index_html_out=$(tr -d '\n' <index.html) 52 + echo "index = '${index_html}'" 53 + echo "index_out = '${index_html_out}'" 54 + test "${index_html}" = "${index_html_out}" 52 55 53 56 test -f page2.html 54 - test "$page2_html" = "$(cat page2.html)" 57 + page2_html_out=$(tr -d '\n' <page2.html) 58 + echo "page2 = '${page2_html}'" 59 + echo "page2_out = '${page2_html_out}'" 60 + test "$page2_html" = "${page2_html_out}" 55 61 } 56 62 57 63 test_list_m() { #@test