#[non_exhaustive]pub struct BlogContext {
pub current_slug: 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 for blog pages, decoupled from the consumer’s Route enum.
The consumer creates this in their blog 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_slug: ReadSignal<String>Current blog post slug (empty on the list/index page).
base_path: StringBase URL path for the blog (e.g. “/blog”).
Callback to navigate to a blog post by slug (empty string = blog index).
site_url: Option<String>Optional full site URL (e.g. https://example.com). Used as the canonical
host for emitted <link rel="canonical">, og:url, and JSON-LD URLs.
Independent of auto_meta — set it whenever you want
kit helpers (sitemap/RSS, 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, Twitter Card, and Article JSON-LD 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, og:url,
and JSON-LD @id only emit when site_url is also set.
markdown_alternate: boolWhen true, BlogPostMeta emits a
<link rel="alternate" type="text/markdown"> pointing at the post’s raw
Markdown source (<base_path>/<slug>.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 when auto_meta is
also on.
Implementations§
Source§impl BlogContext
impl BlogContext
Sourcepub fn new(
current_slug: impl Into<ReadSignal<String>>,
base_path: impl Into<String>,
navigate: Callback<String>,
) -> Self
pub fn new( current_slug: 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 BlogContext
impl Clone for BlogContext
Source§fn clone(&self) -> BlogContext
fn clone(&self) -> BlogContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more