From 357cd1235444b48c61085aabc2e3308836c16b90 Mon Sep 17 00:00:00 2001 From: Timid Robot Zehta Date: Thu, 6 Jun 2024 15:14:02 -0700 Subject: [PATCH 1/5] add script to convert symlinks into a Netlify _redirects format --- config/netlify_redirects.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 config/netlify_redirects.sh diff --git a/config/netlify_redirects.sh b/config/netlify_redirects.sh new file mode 100755 index 00000000000..c19fc342d39 --- /dev/null +++ b/config/netlify_redirects.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# +# Convert symlinks into a Netlify _redirects format +# +set -o errexit +set -o errtrace +set -o nounset + +# shellcheck disable=SC2154 +trap '_es=${?}; + printf "${0}: line ${LINENO}: \"${BASH_COMMAND}\""; + printf " exited with a status of ${_es}\n"; + exit ${_es}' ERR + +for _line in $(cd docs; find -- * -type l -ls | awk '{print $11"###"$13}') +do + symlink="${_line%%#*}" + if [[ "${symlink}" =~ \/ ]] + then + basedir="${symlink%/*}" + else + basedir='' + fi + symlink=${symlink/\/index.html/} + target="${basedir}/${_line##*#}" + target="${target/\/rdf/rdf}" + target="${target/licenses\/..\//}" + echo "/${symlink} /${target} 200" +done | sort -r | column -t From 84beda18d2527ed297f567b396bcb95b3fc43e48 Mon Sep 17 00:00:00 2001 From: Timid Robot Zehta Date: Thu, 6 Jun 2024 15:19:20 -0700 Subject: [PATCH 2/5] hardcode output file --- config/netlify_redirects.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/config/netlify_redirects.sh b/config/netlify_redirects.sh index c19fc342d39..09423f4d9c1 100755 --- a/config/netlify_redirects.sh +++ b/config/netlify_redirects.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Convert symlinks into a Netlify _redirects format +# Convert symlinks into a Netlify _redirects file # set -o errexit set -o errtrace @@ -12,9 +12,11 @@ trap '_es=${?}; printf " exited with a status of ${_es}\n"; exit ${_es}' ERR -for _line in $(cd docs; find -- * -type l -ls | awk '{print $11"###"$13}') +DIR_REPO="$(cd -P -- "${0%/*}/.." && pwd -P)" + +for line in $(cd docs; find -- * -type l -ls | awk '{print $11"###"$13}') do - symlink="${_line%%#*}" + symlink="${line%%#*}" if [[ "${symlink}" =~ \/ ]] then basedir="${symlink%/*}" @@ -26,4 +28,4 @@ do target="${target/\/rdf/rdf}" target="${target/licenses\/..\//}" echo "/${symlink} /${target} 200" -done | sort -r | column -t +done | sort -r | column -t > ${DIR_REPO}/docs/_redirects From d5aa1be4127360924cb7a8146616e625009dbcdd Mon Sep 17 00:00:00 2001 From: Timid Robot Zehta Date: Thu, 6 Jun 2024 15:20:35 -0700 Subject: [PATCH 3/5] fix variable name --- config/netlify_redirects.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/netlify_redirects.sh b/config/netlify_redirects.sh index 09423f4d9c1..6ad4680cad2 100755 --- a/config/netlify_redirects.sh +++ b/config/netlify_redirects.sh @@ -24,7 +24,7 @@ do basedir='' fi symlink=${symlink/\/index.html/} - target="${basedir}/${_line##*#}" + target="${basedir}/${line##*#}" target="${target/\/rdf/rdf}" target="${target/licenses\/..\//}" echo "/${symlink} /${target} 200" From 231592fe4b68cc9f6c8b11734f2a0e1f5d9db6dd Mon Sep 17 00:00:00 2001 From: Timid Robot Zehta Date: Thu, 6 Jun 2024 15:27:36 -0700 Subject: [PATCH 4/5] fix licenses/.. and add pretty urls --- config/netlify_redirects.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/netlify_redirects.sh b/config/netlify_redirects.sh index 6ad4680cad2..f564b34dd84 100755 --- a/config/netlify_redirects.sh +++ b/config/netlify_redirects.sh @@ -26,6 +26,7 @@ do symlink=${symlink/\/index.html/} target="${basedir}/${line##*#}" target="${target/\/rdf/rdf}" - target="${target/licenses\/..\//}" + target="${target/licenses\/../}" echo "/${symlink} /${target} 200" -done | sort -r | column -t > ${DIR_REPO}/docs/_redirects + echo "/${symlink%.html} /${target} 200" +done | sort -r -u | column -t > ${DIR_REPO}/docs/_redirects From a225431d9bda57bd99ff8959d40d66aae082af9e Mon Sep 17 00:00:00 2001 From: Timid Robot Zehta Date: Thu, 6 Jun 2024 15:34:52 -0700 Subject: [PATCH 5/5] add build command documentation --- config/netlify_redirects.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/netlify_redirects.sh b/config/netlify_redirects.sh index f564b34dd84..a512ea886e8 100755 --- a/config/netlify_redirects.sh +++ b/config/netlify_redirects.sh @@ -2,6 +2,10 @@ # # Convert symlinks into a Netlify _redirects file # +# Configure the site in Netlify with: +# +# Build command: ./config/netlify_redirects.sh +# set -o errexit set -o errtrace set -o nounset