diff options
Diffstat (limited to '')
-rwxr-xr-x | scripts/assert-content.sh | 33 | ||||
-rw-r--r-- | site.json | 2 |
2 files changed, 21 insertions, 14 deletions
diff --git a/scripts/assert-content.sh b/scripts/assert-content.sh index 470fcb7..7448c61 100755 --- a/scripts/assert-content.sh +++ b/scripts/assert-content.sh @@ -84,20 +84,27 @@ done echo Asserting unique refs... >&2 KNOWN_IDS=() -for page in $(jq -r '.pages[] | @base64' "${JSON}"); do - URL="$(get-url "$page")" - if ! contains-element "${URL}" "${IGNORED_PAGES[@]}"; then - LANG="$(get-lang "$page")" - REF="$(get-ref "$page")" - ID="${LANG}:${REF}" - - if contains-element "${ID}" "${KNOWN_IDS[@]}"; then - red "Duplicated lang:ref match: '${ID}'." >&2 - exit 1 +assert-unique-ref() { + for page in $1; do + URL="$(get-url "$page")" + if ! contains-element "${URL}" "${IGNORED_PAGES[@]}"; then + LANG="$(get-lang "$page")" + REF="$(get-ref "$page")" + ID="${LANG}:${REF}" + + if contains-element "${ID}" "${KNOWN_IDS[@]}"; then + printf '%s\n' "${KNOWN_IDS[@]}" + red "Duplicated lang:ref match: '${ID}'." >&2 + red "Page: ${URL}." >&2 + exit 1 + fi + + KNOWN_IDS+=("${ID}") # printf '%s\n' "${KNOWN_IDS[@]}" fi + done +} - KNOWN_IDS+=("${ID}") # printf '%s\n' "${KNOWN_IDS[@]}" - fi -done +assert-unique-ref "$(jq -r '.pages[] | @base64' "${JSON}")" +assert-unique-ref "$(jq -r '.posts[] | @base64' "${JSON}")" echo Done. >&2 @@ -31,7 +31,7 @@ "date": "{{ post.date }}", "url": "{{ pastebin.url }}", "lang": "{{ pastebin.lang }}", - "ref": "placeholder-ref", + "ref": "pastebin-ref", "content": {{ pastebin.content | strip_html | jsonify }} }{% unless forloop.last %},{% endunless %} {% endfor %} |