diff options
author | Evan Read <eread@gitlab.com> | 2022-08-02 02:02:02 +0300 |
---|---|---|
committer | Evan Read <eread@gitlab.com> | 2022-08-30 03:22:16 +0300 |
commit | 8451aa75732c7a4def64f39f7ab194d21e9aaddf (patch) | |
tree | 27220ed47a61101b7753268f84b3ada27453dcb6 /scripts | |
parent | 18121b714288fec6b9cd7a28ffae3bce7a2e4222 (diff) |
Add check for identical duplicate entries in global navigationeread/add-duplicate-nav-entry-check
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/check-navigation.sh | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/scripts/check-navigation.sh b/scripts/check-navigation.sh new file mode 100755 index 00000000..69f4a9a6 --- /dev/null +++ b/scripts/check-navigation.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +COLOR_RED="\e[31m" +COLOR_GREEN="\e[32m" +COLOR_RESET="\e[39m" + +DUPLICATED_NAV_ENTRIES=$(sed -n -E "s/.*[section|category|doc|]_url: '(.*)'/\1/p" content/_data/navigation.yaml | sort | uniq -d) + +printf "${COLOR_GREEN}INFO: Checking for identical duplicate global navigation entries...${COLOR_RESET}\n" + +if [[ -n $DUPLICATED_NAV_ENTRIES ]]; then + for DUPLICATED_NAV_ENTRY in $DUPLICATED_NAV_ENTRIES; do + printf "${COLOR_RED}ERROR (identical duplicate entry):${COLOR_RESET} %s\n" "${DUPLICATED_NAV_ENTRY}" + done + exit 1 +else + printf "${COLOR_GREEN}INFO: No identical duplicate entries found!${COLOR_RESET}\n" + exit 0 +fi |