File tree Expand file tree Collapse file tree
ja/docusaurus-plugin-content-docs/current/concepts
zh-Hans/docusaurus-plugin-content-docs/current/concepts
zh-Hant/docusaurus-plugin-content-docs/current/concepts Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -422,8 +422,11 @@ import ThemedImage from '@theme/ThemedImage'
422422 }}
423423/>
424424
425- The nested ` SettingsRouter ` handles all URLs that start with ` /settings ` . Additionally, it redirects URLs that are not
426- matched to the main ` NotFound ` route. So ` /settings/gibberish ` will redirect to ` /404 ` .
425+ The nested ` SettingsRouter ` handles all URLs that start with ` /settings ` . The outer router
426+ defines a separate ` SettingsSlash ` variant for ` /settings/ ` and redirects it to ` SettingsRoot ` ,
427+ because the inner ` SettingsRoute ` only defines routes without a bare trailing slash
428+ (see [ Trailing Slashes] ( #trailing-slashes ) ). Unrecognized sub-paths like ` /settings/gibberish `
429+ are redirected to the main ` NotFound ` route at ` /404 ` .
427430
428431:::caution
429432
@@ -449,6 +452,8 @@ enum MainRoute {
449452 Contact ,
450453 #[at(" /settings" )]
451454 SettingsRoot ,
455+ #[at(" /settings/" )]
456+ SettingsSlash ,
452457 #[at(" /settings/{*_rest}" )]
453458 Settings { _rest : String },
454459 #[not_found]
@@ -475,6 +480,7 @@ fn switch_main(route: MainRoute) -> Html {
475480 MainRoute :: News => html! {<h1 >{" News" }</ h1 >},
476481 MainRoute :: Contact => html! {<h1 >{" Contact" }</ h1 >},
477482 MainRoute :: SettingsRoot | MainRoute :: Settings { .. } => html! { <Switch <SettingsRoute > render = {switch_settings } / > },
483+ MainRoute :: SettingsSlash => html! { <Redirect <MainRoute > to = {MainRoute :: SettingsRoot }/ > },
478484 MainRoute :: NotFound => html! {<h1 >{" Not Found" }</ h1 >},
479485 }
480486}
Original file line number Diff line number Diff line change @@ -393,7 +393,7 @@ import ThemedImage from '@theme/ThemedImage'
393393 }}
394394/>
395395
396- ネストされた ` SettingsRouter ` は、すべての ` /settings ` で始まる URL を処理します。また、一致しない URL をメインの ` NotFound ` ルートにリダイレクトします。したがって、 ` /settings/gibberish ` は ` /404 ` にリダイレクトされます。
396+ ネストされた ` SettingsRouter ` は、すべての ` /settings ` で始まる URL を処理します。外側のルーターでは ` /settings/ ` 用に別の ` SettingsSlash ` バリアントを定義し、 ` SettingsRoot ` にリダイレクトします。これは、内側の ` SettingsRoute ` が末尾スラッシュのみのルートを定義していないためです( [ 末尾のスラッシュ ] ( #末尾のスラッシュ ) を参照)。 ` /settings/gibberish ` のような認識されないサブパスは、メインの ` NotFound ` ルート ` /404 ` にリダイレクトされます。
397397
398398:::caution
399399
@@ -419,6 +419,8 @@ enum MainRoute {
419419 Contact ,
420420 #[at(" /settings" )]
421421 SettingsRoot ,
422+ #[at(" /settings/" )]
423+ SettingsSlash ,
422424 #[at(" /settings/{*_rest}" )]
423425 Settings { _rest : String },
424426 #[not_found]
@@ -445,6 +447,7 @@ fn switch_main(route: MainRoute) -> Html {
445447 MainRoute :: News => html! {<h1 >{" News" }</ h1 >},
446448 MainRoute :: Contact => html! {<h1 >{" Contact" }</ h1 >},
447449 MainRoute :: SettingsRoot | MainRoute :: Settings { .. } => html! { <Switch <SettingsRoute > render = {switch_settings } / > },
450+ MainRoute :: SettingsSlash => html! { <Redirect <MainRoute > to = {MainRoute :: SettingsRoot }/ > },
448451 MainRoute :: NotFound => html! {<h1 >{" Not Found" }</ h1 >},
449452 }
450453}
Original file line number Diff line number Diff line change @@ -393,7 +393,7 @@ import ThemedImage from '@theme/ThemedImage'
393393 }}
394394/>
395395
396- 嵌套的 ` SettingsRouter ` 处理所有以 ` /settings ` 开头的 URL。此外,它会将未匹配的 URL 重定向到主 ` NotFound ` 路由。因此, ` /settings/gibberish ` 将重定向到 ` /404 ` 。
396+ 嵌套的 ` SettingsRouter ` 处理所有以 ` /settings ` 开头的 URL。外层路由器为 ` /settings/ ` 定义了一个单独的 ` SettingsSlash ` 变体,并将其重定向到 ` SettingsRoot ` ,因为内层 ` SettingsRoute ` 没有定义仅含尾部斜杠的路由(参见 [ 尾部斜杠 ] ( #尾部斜杠 ) )。无法识别的子路径(如 ` /settings/gibberish ` )会重定向到主 ` NotFound ` 路由 ` /404 ` 。
397397
398398:::caution
399399
@@ -419,6 +419,8 @@ enum MainRoute {
419419 Contact ,
420420 #[at(" /settings" )]
421421 SettingsRoot ,
422+ #[at(" /settings/" )]
423+ SettingsSlash ,
422424 #[at(" /settings/{*_rest}" )]
423425 Settings { _rest : String },
424426 #[not_found]
@@ -445,6 +447,7 @@ fn switch_main(route: MainRoute) -> Html {
445447 MainRoute :: News => html! {<h1 >{" News" }</ h1 >},
446448 MainRoute :: Contact => html! {<h1 >{" Contact" }</ h1 >},
447449 MainRoute :: SettingsRoot | MainRoute :: Settings { .. } => html! { <Switch <SettingsRoute > render = {switch_settings } / > },
450+ MainRoute :: SettingsSlash => html! { <Redirect <MainRoute > to = {MainRoute :: SettingsRoot }/ > },
448451 MainRoute :: NotFound => html! {<h1 >{" Not Found" }</ h1 >},
449452 }
450453}
Original file line number Diff line number Diff line change @@ -393,7 +393,7 @@ import ThemedImage from '@theme/ThemedImage'
393393 }}
394394/>
395395
396- 嵌套的 ` SettingsRouter ` 處理所有以 ` /settings ` 開頭的 URL。此外,它會將未符合的 URL 重新導向到主 ` NotFound ` 路由。因此, ` /settings/gibberish ` 將會重新導向到 ` /404 ` 。
396+ 嵌套的 ` SettingsRouter ` 處理所有以 ` /settings ` 開頭的 URL。外層路由器為 ` /settings/ ` 定義了一個單獨的 ` SettingsSlash ` 變體,並將其重新導向到 ` SettingsRoot ` ,因為內層 ` SettingsRoute ` 沒有定義僅含尾部斜線的路由(參見 [ 尾部斜線 ] ( #尾部斜線 ) )。無法識別的子路徑(如 ` /settings/gibberish ` )會重新導向到主 ` NotFound ` 路由 ` /404 ` 。
397397
398398:::caution
399399
@@ -419,6 +419,8 @@ enum MainRoute {
419419 Contact ,
420420 #[at(" /settings" )]
421421 SettingsRoot ,
422+ #[at(" /settings/" )]
423+ SettingsSlash ,
422424 #[at(" /settings/{*_rest}" )]
423425 Settings { _rest : String },
424426 #[not_found]
@@ -445,6 +447,7 @@ fn switch_main(route: MainRoute) -> Html {
445447 MainRoute :: News => html! {<h1 >{" News" }</ h1 >},
446448 MainRoute :: Contact => html! {<h1 >{" Contact" }</ h1 >},
447449 MainRoute :: SettingsRoot | MainRoute :: Settings { .. } => html! { <Switch <SettingsRoute > render = {switch_settings } / > },
450+ MainRoute :: SettingsSlash => html! { <Redirect <MainRoute > to = {MainRoute :: SettingsRoot }/ > },
448451 MainRoute :: NotFound => html! {<h1 >{" Not Found" }</ h1 >},
449452 }
450453}
You can’t perform that action at this time.
0 commit comments