diff options
Diffstat (limited to '')
-rw-r--r-- | _layouts/default.html | 2 | ||||
-rw-r--r-- | _layouts/index.html | 20 | ||||
-rw-r--r-- | default.nix | 4 | ||||
-rwxr-xr-x | scripts/tidy-content.sh | 40 |
4 files changed, 55 insertions, 11 deletions
diff --git a/_layouts/default.html b/_layouts/default.html index 1ff8c1d..6416f57 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -57,7 +57,7 @@ </header> <main> - <h1>{{ page.title }}</h1> + {% if page.title %}<h1>{{ page.title }}</h1>{% endif %} {{ content }} </main> diff --git a/_layouts/index.html b/_layouts/index.html index 3c145d0..73b97ef 100644 --- a/_layouts/index.html +++ b/_layouts/index.html @@ -2,12 +2,14 @@ layout: default --- <h1>{{ site.t.recent_posts[page.lang] }}</h1> -<ul> - {%- for post in site.posts -%} - {% if post.lang == page.lang %} - <li> - <a href="{{ post.url }}">{{ post.title | escape }}</a> - {{ post.date | date: site.t.date_format[page.lang] }} - </li> - {% endif %} - {%- endfor -%} -</ul> +{% if site.posts.size > 0 %} + <ul> + {%- for post in site.posts -%} + {% if post.lang == page.lang %} + <li> + <a href="{{ post.url }}">{{ post.title | escape }}</a> - {{ post.date | date: site.t.date_format[page.lang] }} + </li> + {% endif %} + {%- endfor -%} + </ul> +{% endif %} diff --git a/default.nix b/default.nix index c664429..0f98063 100644 --- a/default.nix +++ b/default.nix @@ -33,9 +33,10 @@ in rec { }); docs = utils.baseTask.overrideAttrs (baseAttrs: { name = "${baseAttrs.name}-docs"; - buildInputs = [ jekyllEnv ]; + buildInputs = [ jekyllEnv pkgs.html-tidy ]; buildPhase = '' jekyll build -d $out + find $out -type f -name '*.html' | xargs -I{} tidy -errors -utf8 -indent -modify {} ''; }); }; @@ -51,6 +52,7 @@ in rec { buildInputs = [ jekyllEnv (pkgs.hunspellWithDicts (with pkgs.hunspellDicts; [ en-us ])) + pkgs.html-tidy ]; }; publishScript = utils.overwritingPublishScript { diff --git a/scripts/tidy-content.sh b/scripts/tidy-content.sh new file mode 100755 index 0000000..53533a1 --- /dev/null +++ b/scripts/tidy-content.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +end="\033[0m" +red="\033[0;31m" +red() { echo -e "${red}${1}${end}"; } + +usage() { + red "Missing argument <${1}>.\n" + cat <<EOF +Usage: + $0 <INPUT_DIR> + + Arguments: + INPUT_DIR Input directory with the static HTML to be tidy-ed + +Examples: + $0 _site/ +EOF +} + +INPUT_DIR="${1:-}" +[[ -z "${INPUT_DIR}" ]] && { + usage 'INPUT_DIR' + exit 2 +} + +format() { + FILE="${1}" + # mktemp + if ! tidy -utf8 -indent -modify "${FILE}" 2>> tmp-error.txt; then + cat <(echo "${FILE}") tmp-error.txt >> errors.txt + echo "Error in formatting '${FILE}'. See errors.txt for more detail." + exit 1 + fi +} +export -f format + +find "${INPUT_DIR}" -type f -name '*.html' -print0 | \ + xargs -0 -I{} bash -c "format {}" |