feat: add base_path support for mounting under a URL prefix

Wraps the router in axum's `nest` when BOOK_BASE_PATH is set, prepends
the prefix to form actions and asset URLs, and exposes a {{base}}
template placeholder. basePath option added to the NixOS module.
This commit is contained in:
Lewis Wynne 2026-04-29 01:40:48 +01:00
parent b784f4dd9c
commit 6ca40e2321
9 changed files with 251 additions and 14 deletions

View file

@ -15,6 +15,8 @@
entries - Approved guestbook entries, newest first.
style - Custom CSS from BOOK_STYLE or BOOK_STYLE_FILE, wrapped in
a <style> tag. Uses built-in default.css when neither is set.
base - URL prefix the guestbook is mounted at (BOOK_BASE_PATH).
Empty when serving at the domain root.
See default.css for available CSS classes on rendered elements.
-->

View file

@ -6,6 +6,7 @@
title - Site title (BOOK_SITE_TITLE).
style - Custom CSS (same as the main template).
base - URL prefix the guestbook is mounted at (BOOK_BASE_PATH).
Everything else is static — write whatever you want. Use <script> for
dynamic behavior like showing the current time.
@ -21,7 +22,7 @@
<body>
<div class="page-container">
<p>Thanks! Your message is pending approval.</p>
<p><a href="/">&#8592; back</a></p>
<p><a href="{{base}}/">&#8592; back</a></p>
</div>
</body>
</html>