feat(doc): 文档托管到 /doc 路径

- main.rs: static_routes 加 /doc 与 /doc/ 的 301 重定向到
  /doc/yggdrasil/index.html,绕开 Router 的 /:..segments 兜底。
  文档深层路径由 Dioxus 自动托管 public/ 提供,无需额外代码。
- .gitignore: 忽略 public/doc 构建产物(配合 make doc 拷贝)
This commit is contained in:
xfy 2026-06-26 11:04:29 +08:00
parent c024de1b09
commit 33db6dc5aa
2 changed files with 18 additions and 0 deletions

1
.gitignore vendored
View File

@ -10,6 +10,7 @@ public/style.css
public/highlight.css
public/tiptap
public/lightbox
public/doc
/static
.env
docs/superpowers/

View File

@ -391,6 +391,23 @@ fn main() {
"/readyz",
axum::routing::get(crate::api::health::readyz),
)
// /doc 与 /doc/ 重定向到文档入口 /doc/yggdrasil/index.html。
// public/doc/ 由 Dioxus 自动托管,深层路径无需额外处理;仅裸路径需要
// 重定向,否则会落到 Router 的 /:..segments 兜底返回 404 页面。
// 放在 static_routes与 /uploads 同层),不经过 CSRF/超时/缓存中间件,
// 行为与静态资源一致。用 301 永久重定向,让浏览器/书签记住跳转。
.route(
"/doc",
axum::routing::get(|| async {
axum::response::Redirect::permanent("/doc/yggdrasil/index.html")
}),
)
.route(
"/doc/",
axum::routing::get(|| async {
axum::response::Redirect::permanent("/doc/yggdrasil/index.html")
}),
)
.route(
"/uploads/{*path}",
axum::routing::get(crate::api::image::serve_image),