blob: dc62cafe396f12b9caf28d4f1a8f46d99d98d430 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
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"
if [ ! -d "$notes_dir" ]; then
log INFO "Capsule without Notes section"
return
fi
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)
cat <<NOTES >> "$notes_dir/index.gmi.tmp"
That were all notes. Hope they were useful!
=> ../ Go back to main site
NOTES
# Only overwrite if content changed, preserving mtime for template skip logic
generate::safe_overwrite "$notes_dir/index.gmi.tmp" "$notes_dir/index.gmi"
}
|