#[non_exhaustive]pub struct DocsContext {
pub current_path: ReadSignal<String>,
pub base_path: String,
pub navigate: Callback<String>,
pub site_url: Option<String>,
pub auto_meta: bool,
pub markdown_alternate: bool,
}Expand description
Navigation bridge that decouples library components from the consumer’s Route enum.
The consumer creates this in their docs layout wrapper and provides it via use_context_provider.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.current_path: ReadSignal<String>Current docs page path (e.g. “getting-started/introduction”).
base_path: StringBase URL path for docs (e.g. “/docs”).
Callback to navigate to a docs page by content path.
site_url: Option<String>Optional full site URL (e.g. https://example.com). Used as the canonical
host for emitted <link rel="canonical"> and og:url tags. Independent
of auto_meta — set it whenever you want kit helpers
(sitemap generation, canonical URLs) to know the public origin, even if
you suppress automatic meta emission.
auto_meta: boolWhen true, the kit emits per-page <title>, <meta name="description">,
Open Graph and Twitter Card tags from frontmatter. Set to false if your
app manages its own <head> (e.g. brand-specific OG images, structured
data) and the kit’s emissions would conflict. Title and description tags
always emit when this is on; canonical and og:url only emit when
site_url is also set.
markdown_alternate: boolWhen true, DocsPageMeta emits a
<link rel="alternate" type="text/markdown"> pointing at the page’s raw
Markdown source (<base_path>/<path>.md), a discoverability hint for AI
crawlers and “view as Markdown” tooling. Enable this only if your server
actually serves those .md URLs (see server::SeoRouter behind the
server feature). Emitted only for MDX pages (OpenAPI endpoint pages
have no Markdown source), and only when auto_meta
is also on.
Implementations§
Source§impl DocsContext
impl DocsContext
Sourcepub fn new(
current_path: impl Into<ReadSignal<String>>,
base_path: impl Into<String>,
navigate: Callback<String>,
) -> Self
pub fn new( current_path: impl Into<ReadSignal<String>>, base_path: impl Into<String>, navigate: Callback<String>, ) -> Self
Create a context from the three required fields.
The meta fields default to site_url: None, auto_meta: true,
markdown_alternate: false; override them with the with_* setters.
Prefer this over a struct literal — new fields get sensible defaults
here instead of breaking your build.
Sourcepub fn with_site_url(self, site_url: impl Into<String>) -> Self
pub fn with_site_url(self, site_url: impl Into<String>) -> Self
Set the public site origin (e.g. "https://example.com").
Sourcepub fn with_auto_meta(self, auto_meta: bool) -> Self
pub fn with_auto_meta(self, auto_meta: bool) -> Self
Enable or disable automatic per-page meta emission (default: on).
Sourcepub fn with_markdown_alternate(self, markdown_alternate: bool) -> Self
pub fn with_markdown_alternate(self, markdown_alternate: bool) -> Self
Emit <link rel="alternate" type="text/markdown"> tags (default: off).
Trait Implementations§
Source§impl Clone for DocsContext
impl Clone for DocsContext
Source§fn clone(&self) -> DocsContext
fn clone(&self) -> DocsContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more