diff options
author | Romain Gonçalves <me@rgoncalves.se> | 2021-08-08 10:02:01 +0200 |
---|---|---|
committer | Romain Gonçalves <me@rgoncalves.se> | 2021-08-08 10:02:01 +0200 |
commit | a677748e19cc2e490ffcdbd5799755e67ab4ff02 (patch) | |
tree | 2fcbea6eafab16425f6a56ac5bcf83c2d02573f3 /bin/ssg-template | |
parent | fc33ada43aba6d46e6e0dff315b3b753058fa839 (diff) | |
download | rgoncalves.se-a677748e19cc2e490ffcdbd5799755e67ab4ff02.tar.gz |
bin/ssg: Switch for showing date in index
Diffstat (limited to 'bin/ssg-template')
-rw-r--r-- | bin/ssg-template | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/bin/ssg-template b/bin/ssg-template index e0689cb..4da4364 100644 --- a/bin/ssg-template +++ b/bin/ssg-template @@ -10,9 +10,15 @@ _get_value() { # 1: filename # 2: key # stdout: value - local value=$(lowdown -T ms -X "${2}" "${1}" 2>/dev/null) + local value + local ret + + value=$(lowdown -T ms -X "${2}" "${1}" 2>/dev/null) + ret="${?}" + echo "${value:-${3}}" - return "${?}" + + return "${ret}" } _get_value_date() { @@ -139,8 +145,8 @@ _render_index() { title=$(_get_value "${file}" "title" "$(_get_title ${file})") echo "<li>" - if [ $(_get_value "${file}" "index_show_date") ]; then - echo "<span>$(_get_date_human \"${file}\")</span>" + if _get_value "${1}" "index_show_date" >/dev/null; then + echo "<span>$(_get_date_human ${file})</span>" fi echo "<a href=\"${path}\">${title}</a>" echo "</li>" |