2020-03-29 21:18:30 +02:00
|
|
|
returncode=0
|
|
|
|
|
2021-02-13 22:58:04 +01:00
|
|
|
# Parse default routes
|
|
|
|
grep -roh "^ *default: .*" ./pages | awk '{print $2}' | tr -d "'" | sort | uniq > .known_pages
|
|
|
|
|
|
|
|
# Parse aliases
|
|
|
|
grep -rh "^---$" ./pages -B 50 | grep "^ *\- '/" | awk '{print $2}' | tr -d "'" | sort | uniq >> .known_pages
|
|
|
|
|
2020-03-29 21:18:30 +02:00
|
|
|
# Find all markdown links and generate a list of filename.md:N:linktarget (with N the line number)
|
2021-02-13 22:58:04 +01:00
|
|
|
for LINK in $(grep -nr -o -E "\]\(\/?(\w|-)+\)" ./pages)
|
2020-03-29 21:18:30 +02:00
|
|
|
do
|
2021-02-13 22:58:04 +01:00
|
|
|
PAGE=$(echo $LINK | awk -F: '{print $3}' | tr -d ']()/')
|
2020-03-29 21:18:30 +02:00
|
|
|
|
2021-02-13 22:58:04 +01:00
|
|
|
grep -qw "$PAGE" ./.known_pages || { echo $LINK; returncode=1; }
|
2020-03-29 21:18:30 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
exit $returncode
|