diff options
author | Evan Read <eread@gitlab.com> | 2022-09-02 16:45:09 +0300 |
---|---|---|
committer | Sarah German <sgerman@gitlab.com> | 2022-09-02 16:45:09 +0300 |
commit | 303863edc7b550eca1c3a0d9a16771ae7c08b4c6 (patch) | |
tree | 805f5c9dc400c42843d444146e7f0c77774704ca /scripts | |
parent | f81133efc9b707678affacd342f9c092c7225896 (diff) |
Add check for index.html to global navigation check script
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/check-navigation.sh | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/scripts/check-navigation.sh b/scripts/check-navigation.sh index 69f4a9a6..9274e576 100755 --- a/scripts/check-navigation.sh +++ b/scripts/check-navigation.sh @@ -3,17 +3,37 @@ COLOR_RED="\e[31m" COLOR_GREEN="\e[32m" COLOR_RESET="\e[39m" +RETURN_CODE=0 + DUPLICATED_NAV_ENTRIES=$(sed -n -E "s/.*[section|category|doc|]_url: '(.*)'/\1/p" content/_data/navigation.yaml | sort | uniq -d) +# shellcheck disable=2059 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 + RETURN_CODE=1 else + # shellcheck disable=2059 printf "${COLOR_GREEN}INFO: No identical duplicate entries found!${COLOR_RESET}\n" - exit 0 fi + +NAV_ENTRIES_WITH_INDEX=$(sed -n -E "s/.*[section|category|doc|]_url: '(.*)'/\1/p" content/_data/navigation.yaml | grep -e "index.html" | grep -v "index.html.") + +# shellcheck disable=2059 +printf "${COLOR_GREEN}INFO: Checking for global navigation entries with index.html...${COLOR_RESET}\n" + +if [[ -n $NAV_ENTRIES_WITH_INDEX ]]; then + for NAV_ENTRY_WITH_INDEX in $NAV_ENTRIES_WITH_INDEX; do + printf "${COLOR_RED}ERROR (entry with index.html):${COLOR_RESET} %s\n" "${NAV_ENTRY_WITH_INDEX}" + done + RETURN_CODE=1 +else + # shellcheck disable=2059 + printf "${COLOR_GREEN}INFO: No entries with index.html found!${COLOR_RESET}\n" +fi + +if [[ $RETURN_CODE == 1 ]]; then exit 1; else exit 0; fi |