feat: add rewrites for older versions

This commit is contained in:
Jose Diaz-Gonzalez
2022-09-05 19:03:56 -04:00
parent 8fe33a0e41
commit d3890fee9f
2 changed files with 42 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash
set -eo pipefail
set -x
readonly ROOT_DIR="$(cd "$(dirname "$(dirname "${BASH_SOURCE[0]}")")" && pwd)"
@@ -19,6 +20,8 @@ main() {
rm -rf tmp/docs-build/assets
cp -r docs-main/assets tmp/docs-build/assets
cp docs-main/_build/app-nginx.conf.sigil tmp/docs-build/app-nginx.conf.sigil
mkdir -p tmp/docs-build/nginx.conf.d
make docs-build
mv site tmp/docs-build/docs
@@ -39,6 +42,7 @@ main() {
if [[ "$major" -lt 1 ]]; then
if [[ "$current_version" != "$version" ]] && [[ "$minor" -lt 28 ]]; then
echo "rewrite ^/docs~$version/(.*)$ /docs~$current_version\$1 last;" > "tmp/docs-build/nginx.conf.d/$version.conf"
rm -rf "tmp/docs-build/docs~v${version}"
patch=$((patch - 1))
continue

38
docs/_build/app-nginx.conf.sigil vendored Normal file
View File

@@ -0,0 +1,38 @@
worker_processes 1;
error_log stderr;
pid nginx.pid;
daemon off;
events {
worker_connections 768;
}
http {
types_hash_max_size 2048;
include mime.types;
charset UTF-8;
server {
listen {{ $.PORT }};
server_name _;
{{ if ne $.NGINX_ROOT "" }}
root /app/www/{{ $.NGINX_ROOT }};
{{ else }}
root /app/www;
{{ end }}
index index.html;
port_in_redirect off;
include /app/www/nginx.conf.d/*.conf;
location ^~ /nginx.conf.d/ {
return 404;
}
location / {
{{ if ne $.NGINX_DEFAULT_REQUEST "" }}
try_files $uri $uri/ /{{ $.NGINX_DEFAULT_REQUEST }};
{{ else }}
try_files $uri $uri/ =404;
{{ end }}
}
}
}