From df357d62bbf2aca388864ee789e779da79f49f53 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Wed, 12 Aug 2020 09:58:34 -0300 Subject: scripts/assert-content.sh: Add check for missing title --- scripts/assert-content.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/assert-content.sh b/scripts/assert-content.sh index d466b05..d8fe89f 100755 --- a/scripts/assert-content.sh +++ b/scripts/assert-content.sh @@ -42,7 +42,13 @@ get-date() { echo "${1}" | base64 --decode | jq -r .date } +get-title() { + echo "${1}" | base64 --decode | jq -r .title +} + LANGS=(en pt) +IGNORED_PAGES=(site.json sitemap.xml *.atom) + assert-frontmatter() { F="${1}" LANG="$(get-lang "$F")" @@ -50,6 +56,11 @@ assert-frontmatter() { URL="$(get-url "$F")" [[ -z "${LANG}" ]] && fail-attr 'lang' "${URL}" [[ -z "${REF}" ]] && fail-attr 'ref' "${URL}" + if ! contains-element "${URL}" "${IGNORED_PAGES[@]}"; then + TITLE="$(get-title "$F")" + [[ -z "${TITLE}" ]] && fail-attr 'title' "${URL}" + fi + if ! contains-element "${LANG}" "${LANGS[@]}"; then red "Invalid lang '${LANG}' in ${URL}." >&2 exit 1 @@ -70,7 +81,6 @@ for post in $(jq -r '.posts[] | @base64' "${JSON}"); do done echo Linting pages... >&2 -IGNORED_PAGES=(site.json sitemap.xml *.atom) for page in $(jq -r '.pages[] | @base64' "${JSON}"); do URL="$(get-url "$page")" if ! contains-element "${URL}" "${IGNORED_PAGES[@]}"; then -- cgit v1.2.3