aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ssg9
-rw-r--r--bin/ssg-template14
2 files changed, 16 insertions, 7 deletions
diff --git a/bin/ssg b/bin/ssg
index b96e01f..f70a3f9 100755
--- a/bin/ssg
+++ b/bin/ssg
@@ -10,7 +10,7 @@ OUT="out"
. ./bin/ssg-template
_log() {
- echo [${0}] $@
+ echo [${0}] "$@"
}
_to_html() {
@@ -46,6 +46,7 @@ _convert_urls() {
main() {
local file
+ local out_path
# template files
for template in header footer; do
@@ -56,7 +57,9 @@ main() {
# markdown files
for file in $(find "${SRC}" -iname "*.md"); do
- if [ "${file}" -ot $(_get_out_path "${file}") ]; then
+ out_path=$(_get_out_path "${file}")
+
+ if [ "${file}" -ot "${out_path}" ]; then
_log "! ${file}"
continue
fi
@@ -89,7 +92,7 @@ main() {
# Concatenate temporary files to final page
m4 templates/default.html > "${TMP_FILE}"
- install -D "${TMP_FILE}" $(_get_out_path "${file}")
+ install -D "${TMP_FILE}" "${out_path}"
done
# html files
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>"
remember that computers suck.