diff options
author | EuAndreh <eu@euandre.org> | 2020-08-10 10:00:46 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2020-08-10 10:00:46 -0300 |
commit | d54cfed1ad069d4e063a4c0463f96ba04060a36c (patch) | |
tree | b2000cbafadc30948b81eb0445f8de63352811f6 | |
parent | Finish migrating til.md (diff) | |
download | euandre.org-d54cfed1ad069d4e063a4c0463f96ba04060a36c.tar.gz euandre.org-d54cfed1ad069d4e063a4c0463f96ba04060a36c.tar.xz |
assert-content.sh: Look at post refs too, not only pages
-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 %} |