1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
use *;
use crateDocsContext;
use crate;
use crateDocsRegistry;
/// Signals returned by [`use_docs_providers`] so the consumer's header RSX
/// can reference them (e.g. to wire up a search button or drawer toggle).
/// 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.
///
/// ```rust,ignore
/// 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() });
/// }));
/// ```
/// One-call setup for all the context providers that `DocsLayout` and its
/// children expect.
///
/// Call this in your docs layout wrapper **before** rendering `DocsLayout`:
///
/// ```rust,ignore
/// let providers = use_docs_providers(&*DOCS, docs_ctx);
/// // Use providers.search_open / providers.drawer_open in your header RSX
/// ```
///
/// This replaces the manual calls to:
/// - `use_context_provider(|| registry)`
/// - `use_context_provider(|| docs_ctx)`
/// - `use_signal(|| false)` × 2 + `use_context_provider` for search_open / DrawerOpen