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:
parent
c024de1b09
commit
33db6dc5aa
1
.gitignore
vendored
1
.gitignore
vendored
@ -10,6 +10,7 @@ public/style.css
|
|||||||
public/highlight.css
|
public/highlight.css
|
||||||
public/tiptap
|
public/tiptap
|
||||||
public/lightbox
|
public/lightbox
|
||||||
|
public/doc
|
||||||
/static
|
/static
|
||||||
.env
|
.env
|
||||||
docs/superpowers/
|
docs/superpowers/
|
||||||
|
|||||||
17
src/main.rs
17
src/main.rs
@ -391,6 +391,23 @@ fn main() {
|
|||||||
"/readyz",
|
"/readyz",
|
||||||
axum::routing::get(crate::api::health::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(
|
.route(
|
||||||
"/uploads/{*path}",
|
"/uploads/{*path}",
|
||||||
axum::routing::get(crate::api::image::serve_image),
|
axum::routing::get(crate::api::image::serve_image),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user