summaryrefslogtreecommitdiff
path: root/lib/notes.source.sh
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2022-05-29 08:13:56 +0100
committerPaul Buetow <paul@buetow.org>2022-05-29 08:13:56 +0100
commit252432fae23e58f97b825f855ece4f6e8e1cf39f (patch)
treea21858b275f171b8d31a41915ee1b996b5de79e0 /lib/notes.source.sh
parent7ab29e00e7b8ed9327c277592ba2f84ff04277eb (diff)
add notes section - can override CSS styles by section
Diffstat (limited to 'lib/notes.source.sh')
-rw-r--r--lib/notes.source.sh34
1 files changed, 34 insertions, 0 deletions
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 > "$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"
+}