From 252432fae23e58f97b825f855ece4f6e8e1cf39f Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 29 May 2022 08:13:56 +0100 Subject: add notes section - can override CSS styles by section --- lib/notes.source.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 lib/notes.source.sh (limited to 'lib/notes.source.sh') diff --git a/lib/notes.source.sh b/lib/notes.source.sh new file mode 100644 index 0000000..559b218 --- /dev/null +++ b/lib/notes.source.sh @@ -0,0 +1,34 @@ +notes::_get_notes () { + local -r notes_dir="$CONTENT_BASE_DIR/gemtext/notes" + local -r gmi_pattern='.*\.gmi$' + + ls "$notes_dir" | + $GREP -E "$gmi_pattern" | + $GREP -v '^index.gmi$' | + sort -r +} + +# Generate a index.gmi in the ./notes subdir. +notes::generate () { + local -r notes_dir="$CONTENT_BASE_DIR/gemtext/notes" + log INFO "Generating Notes index for $notes_dir" + +cat < "$notes_dir/index.gmi.tmp" +# Notes on $DOMAIN + +## $SUBTITLE + +NOTES + + while read -r gmi_file; do + # Extract first heading as post title. + local title=$($SED -n '/^# / { s/# //; p; q; }' \ + "$notes_dir/$gmi_file" | tr '"' "'") + + echo "=> ./$gmi_file $title" >> \ + "$notes_dir/index.gmi.tmp" + done < <(notes::_get_notes) + + mv "$notes_dir/index.gmi.tmp" "$notes_dir/index.gmi" + git::add gemtext "$notes_dir/index.gmi" +} -- cgit v1.2.3