pub fn use_docs_context(
current_path: String,
base_path: impl Into<String>,
navigate: Callback<String>,
) -> DocsContextExpand description
Build a DocsContext from the current docs path as a plain String.
Prefer this over DocsContext::new when the path comes from your router.
use_route::<Route>() returns a plain value, not a signal, so wrapping it
yourself with use_memo(move || ...) reads no reactive source: the memo
runs once and never again, freezing the sidebar highlight, tab sync and
mobile-drawer auto-close on the first page visited. (use_memo paired with
use_reactive! is correct, but easy to forget.)
Taking the path by value removes the trap — this hook re-runs with your layout component on every navigation and rewraps the path reactively.
ⓘ
let route = use_route::<Route>();
let current_path = match route {
Route::DocsPage { slug } => slug.join("/"),
_ => String::new(),
};
let docs_ctx = use_docs_context(current_path, "/docs", Callback::new(move |path: String| {
nav.push(Route::DocsPage { slug: path.split('/').map(String::from).collect() });
}));