can either link to redoc hosted elsewhere or make a local copy: - for local frontend build, just redirect to http://localhost:30870/api/redoc - for deployment, make local copy: run copy-api-docs.sh, copy locally from prod and serve at /api/ - copy-api-docs.sh copies openapi.json, redoc and logo to /api/ dir - if analytics enabled, also injects analytics scripts - for local testing, run copy-api-docs.sh and then run mkdocs serve - ci: copy from prod server - fixes #1582
16 lines
763 B
Bash
Executable File
16 lines
763 B
Bash
Executable File
#!/usr/bin/env bash
|
|
CURR=$(dirname "${BASH_SOURCE[0]}")
|
|
|
|
TARGET=$CURR/docs/api/
|
|
mkdir $TARGET
|
|
curl "$DOCS_SOURCE_URL/api/openapi.json" > $TARGET/openapi.json
|
|
curl "$DOCS_SOURCE_URL/api/redoc" > $TARGET/index.html
|
|
curl "$DOCS_SOURCE_URL/docs-logo.svg" > $TARGET/../docs-logo.svg
|
|
|
|
if [ -n $ENABLE_ANALYTICS ]; then
|
|
SCRIPT_1=' <script defer data-domain=\"docs.browsertrix.com\" src=\"https://p.webrecorder.net/js/script.outbound-links.js\"></script>'
|
|
SCRIPT_2=' <script>window.plausible = window.plausible || function () { (window.plausible.q = window.plausible.q || []).push(arguments) }</script>'
|
|
awk "1;/<head>/{ print \"$SCRIPT_1\"; print \"$SCRIPT_2\" }" $TARGET/index.html > $TARGET/index.html.new
|
|
mv $TARGET/index.html.new $TARGET/index.html
|
|
fi
|