aboutsummaryrefslogtreecommitdiffstats
path: root/bin/func
diff options
context:
space:
mode:
authorRomain Gonçalves <me@rgoncalves.se>2021-09-27 21:18:46 +0200
committerRomain Gonçalves <me@rgoncalves.se>2021-09-27 21:18:46 +0200
commit0c44f4afd0c3ee568b7ddbc44fa92f5e89f79ac1 (patch)
tree01e13002d22c0ac77abee1f12e0cbfe5f7dfd061 /bin/func
parent450dba0642ad882e230279d0d6602b85f76d23e7 (diff)
downloadrgoncalves.se-0c44f4afd0c3ee568b7ddbc44fa92f5e89f79ac1.tar.gz
func: Add title generation and possibility to skip
Diffstat (limited to 'bin/func')
-rw-r--r--bin/func21
1 files changed, 21 insertions, 0 deletions
diff --git a/bin/func b/bin/func
index eb3b489..793c722 100644
--- a/bin/func
+++ b/bin/func
@@ -171,11 +171,32 @@ __generate_index() {
echo "</ul>"
}
+__generate_metadata() {
+ # 1: filename
+ # Generate metadata with title
+ local _title
+ local _show_title
+
+ _show_title=$(__get_value "${1}" show_title || true)
+
+ if [ "${_show_title}" = "" ]; then
+ _title=$(__get_value_title "${1}")
+
+ cat <<-EOF
+ <h1 id=\"${_title}\">
+ ${_title}
+ </h1>
+ EOF
+ fi
+}
+
__handle_md() {
# 1: filename
# Handle markdown files.
__lowdown "${1}" > "${tmp_file}.body"
+ __generate_metadata "${1}" > "${tmp_file}.metadata"
+
if [ ! "$(__get_value ${1} index)" = "" ]; then
__generate_index "${1}" > "${tmp_file}.index"
else
remember that computers suck.