From 8fe5387c47196d09063e12ca6b9ad768ad4849b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Gon=C3=A7alves?= Date: Mon, 27 Sep 2021 15:08:34 +0200 Subject: all: Bump to version 3 of static site generation --- bin/ssg-template | 194 ------------------------------------------------------- 1 file changed, 194 deletions(-) delete mode 100644 bin/ssg-template (limited to 'bin/ssg-template') diff --git a/bin/ssg-template b/bin/ssg-template deleted file mode 100644 index eacf2ae..0000000 --- a/bin/ssg-template +++ /dev/null @@ -1,194 +0,0 @@ -#!/bin/sh - -SRC_FILE="${1}" - -_echo_ifset() { - [ ! -z "${1}" ] && echo "${1}" -} - -_get_value() { - # 1: filename - # 2: key - # stdout: value - local value - local ret - - value=$(lowdown -T ms -X "${2}" "${1}" 2>/dev/null) - ret="${?}" - - echo "${value:-${3}}" - - return "${ret}" -} - -_get_value_date() { - _get_value "${1}" "${2}" "1970-01-01" -} - -_get_out_path() { - # 1: filename - # stdout: filename - local path - - path=$(echo "${1}" | sed -e 's/^src/out/g' -e 's/.md$/.html/g' -e 's/_//g') - - if _get_value "${1}" "draft" >/dev/null; then - path="$(dirname ${path})/$(echo ${path} | sha1).html" - fi - - echo "${path}" -} - -_get_final_path() { - # 1: filename - # stdout: filename - _get_out_path "${1}" | sed 's/^out\///g' -} - -_get_title() { - # 1: filename - local title - local file_title - - file_title=$(basename "${1}" | sed 's/\..*//g' | tr - " ") - title=$(_get_value "${1}" "title" "${file_title}") - - echo "${title}" -} - -_get_date_human() { - # 1: filename - date -j -f "%Y-%m-%d" $(_get_value_date ${1} "date") +"%B %d, %Y" -} - -_get_index_files() { - # 1: filename - local path - - path=$(_get_value "${1}" index) - find "src/${path}" -mindepth 1 -maxdepth 1 -} - -_sort_index_per_date() { - # 1: filename - local files - local file - local date - - for file in $(_get_index_files "${1}"); do - date=$(_get_value_date "${file}" "date") - files="${files} ${date}@${file}" - done - - echo ${files} | tr " " "\n" | sort -rn | cut -d "@" -f 2 -} - -_get_filetype() { - # 1: filename - local filetype - - filetype=$(ls -ld "${1}" | cut -c 1) - - case "${filetype}" in - -) - filetype="file" - ;; - d) - filetype="directory" - ;; - esac - - echo "${filetype}" -} - -_get_chapters() { - # 1: filename - grep "^#" "${1}" | sed 's/# /#_/g' -} - -_get_chapter_title() { - # 1: chapter - echo "${1}" | sed -e 's/#_//' -e 's/#//g' -} - -_parse_option() { - # 1: metadata - # 2: key - echo "${metadata}" | grep "^${2}" -} - -_cleanup_tmp_file() { - [ -f "${1}" ] && rm "${1}" -} - -_parse_metadata() { - # 1: filename - sed -n '/^$/q;p' "${file}" | grep "^.*: .*$" -} - -_render_metadata() { - # 1: filename - # 2: output - local key - local value - local title - - # _ENABLED_METADATA="date author" - title=$(_get_value "${1}" "title") - - echo "" - - if [ "${title}" ]; then - echo "

${title}

" - fi -} - -_render_index() { - # 1: filename - # 2: out - # 3: path - local file - local path - local title - - echo "" -} - -_render_toc() { - local chapter - local chapter_title - - echo "" -} -- cgit v1.2.3