Files
horizon-airdef/website/Caddyfile
T
Ludovic Marie 4a9ca29887 Website: the API portal at /docs/api, with Markdown tables
The repository's docs/api/ (the portal, its surface pages and the generated mod and
server references) is built into the docs section: /docs/api is its README and
/docs/api/<page> each page, in two nav groups, "Build on Horizon" and "API reference".
The pages are read from the checkout or from main on GitHub, like the README, so the
site never holds a copy. Links between portal pages become the site's (and the build's
link check covers them); other relative links go to the file on GitHub.

The renderer gains tables: the "Ways in" table, the references and the other tables
on the site (apis, performance) showed as raw pipes. A link whose label is a code span
no longer throws.

Caddy and the dev server route /docs/api/<page> and redirect /docs/api/ to /docs/api;
Railway rebuilds when docs/api/ changes. /docs/mods links the Mod API, its reference
and its ways in; the summary page is now "APIs at a glance".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 16:14:03 +01:00

68 lines
2.8 KiB
Caddyfile

# Serves dist/ on Railway's $PORT. Fingerprinted CSS and JS are cached for a year,
# media for a week, and the page itself is always revalidated. The site lives at
# https://playhorizon.dev: Railway's own *.up.railway.app address redirects there, so the
# page is indexed once. Railway's healthcheck (Host: healthcheck.railway.app) is still served.
{
admin off
auto_https off
persist_config off
}
:{$PORT:8080} {
root * /srv
@railway header_regexp Host ^[^.]+\.up\.railway\.app(:[0-9]+)?$
redir @railway https://playhorizon.dev{uri} permanent
encode zstd gzip
header {
X-Content-Type-Options nosniff
Referrer-Policy strict-origin-when-cross-origin
X-Frame-Options DENY
Permissions-Policy "interest-cohort=(), browsing-topics=(), camera=(), microphone=(), geolocation=()"
Content-Security-Policy "default-src 'self'; script-src 'self' {$CSP_SCRIPT}; style-src 'self' {$CSP_STYLE}; img-src 'self' data: https://avatars.githubusercontent.com https://ludovic111.github.io; font-src 'self'; connect-src 'self' https://api.github.com https://raw.githubusercontent.com https://telemetry.playhorizon.dev https://ludovic111.github.io; frame-ancestors 'none'; base-uri 'self'; form-action 'self'"
-Server
}
@assets path /assets/*
header @assets Cache-Control "public, max-age=31536000, immutable"
@media path /media/* /fonts/* /og.png /favicon* /apple-touch-icon.png
header @media Cache-Control "public, max-age=604800"
# The server guide became a section of the documentation.
redir /server /docs/hosting permanent
redir /server.html /docs/hosting permanent
rewrite /privacy /privacy.html
rewrite /releases /releases.html
rewrite /benchmarks /benchmarks.html
@doc path_regexp doc ^/docs/([a-z-]+)$
rewrite @doc /docs/{re.doc.1}.html
# The API portal: /docs/api is its index, /docs/api/<page> its pages.
redir /docs/api/ /docs/api permanent
@apidoc path_regexp apidoc ^/docs/api/([a-z-]+)$
rewrite @apidoc /docs/api/{re.apidoc.1}.html
# The registry's submission service (crates/horizon-mod-registry), over Railway's private network. Unset, the
# form says it isn't open.
handle /api/mods/* {
reverse_proxy {$REGISTRY_UPSTREAM:127.0.0.1:9}
}
# The registry: /mods, /mods/submit and /mods/<id> baked at build time, else the list page, whose script shows a project
# published since.
rewrite /mods /mods.html
@mod {
path_regexp ^/mods/[a-z0-9_]+$
file {path}.html /mods.html
}
rewrite @mod {file_match.relative}
@pages path / /index.html /404.html /privacy.html /releases /releases.html /benchmarks /benchmarks.html /benchmarks.json /docs /docs/* /mods /mods.html /mods/* /sitemap.xml
header @pages Cache-Control "no-cache"
@legal path /LEGAL.md /fonts/*.txt
header @legal Content-Type "text/plain; charset=utf-8"
file_server {
hide .csp-script .csp-style og.html
}
handle_errors {
rewrite * /404.html
file_server
}
}