pub struct BlogConfig { /* private fields */ }Expand description
Builder for constructing a BlogRegistry.
§Example
let registry = BlogConfig::new(include_str!("../blog/_blog.json"), blog_content_map())
.with_posts_per_page(9)
.with_theme_toggle("light", "dark", "dark")
.build();Implementations§
Source§impl BlogConfig
impl BlogConfig
Sourcepub fn new(
manifest_json: &str,
content_map: HashMap<&'static str, &'static str>,
) -> Self
pub fn new( manifest_json: &str, content_map: HashMap<&'static str, &'static str>, ) -> Self
Create a new builder from a _blog.json string and a content map.
Sourcepub fn with_posts_per_page(self, n: usize) -> Self
pub fn with_posts_per_page(self, n: usize) -> Self
Set the number of posts per page for pagination (default: 9).
Sourcepub fn with_category_base_path(self, path: &str) -> Self
pub fn with_category_base_path(self, path: &str) -> Self
Enable linkable tag categories under a root-relative path.
Register routes for {base}/:slug and {base}/:slug/page/:page
rendering crate::BlogCategoryPage (page numbers start at one).
With this unset, existing tag buttons retain their local filtering behavior
and no category URLs are emitted into the sitemap.
Sourcepub fn with_date_format(self, fmt: &str) -> Self
pub fn with_date_format(self, fmt: &str) -> Self
Set the date display format (default: “%B %d, %Y”).
Sourcepub fn with_theme(self, theme: &str) -> Self
pub fn with_theme(self, theme: &str) -> Self
Set a single theme (no toggle button).
Sourcepub fn with_theme_toggle(self, light: &str, dark: &str, default: &str) -> Self
pub fn with_theme_toggle(self, light: &str, dark: &str, default: &str) -> Self
Enable a light/dark theme toggle.
Sourcepub fn build(self) -> BlogRegistry
pub fn build(self) -> BlogRegistry
Build the BlogRegistry.
§Panics
Panics with a descriptive message if _blog.json fails to parse.
Use Self::try_build to handle the error yourself.
Sourcepub fn try_build(self) -> Result<BlogRegistry, DocsKitError>
pub fn try_build(self) -> Result<BlogRegistry, DocsKitError>
Build the BlogRegistry, returning an error instead of panicking when
_blog.json fails to parse.