pub struct SsgConfigBuilder { /* private fields */ }Expand description
Builder for SsgConfig.
Implementations§
Source§impl SsgConfigBuilder
§Examples
use ssg::cmd::SsgConfig;
let config = SsgConfig::builder()
.site_name("My Site".to_string())
.base_url("http://example.com".to_string())
.build()
.unwrap();
impl SsgConfigBuilder
§Examples
use ssg::cmd::SsgConfig;
let config = SsgConfig::builder()
.site_name("My Site".to_string())
.base_url("http://example.com".to_string())
.build()
.unwrap();Sourcepub fn site_name(self, name: String) -> Self
pub fn site_name(self, name: String) -> Self
Sets the site name for the configuration.
§Examples
use ssg::cmd::SsgConfig;
let cfg = SsgConfig::builder().site_name("Hello".into()).build().unwrap();
assert_eq!(cfg.site_name, "Hello");Sourcepub fn base_url(self, url: String) -> Self
pub fn base_url(self, url: String) -> Self
Sets the base URL for the configuration.
§Examples
use ssg::cmd::SsgConfig;
let cfg = SsgConfig::builder()
.base_url("https://example.com".into())
.build()
.unwrap();
assert_eq!(cfg.base_url, "https://example.com");Sourcepub fn content_dir(self, dir: PathBuf) -> Self
pub fn content_dir(self, dir: PathBuf) -> Self
Sets the content directory for the configuration.
§Examples
use ssg::cmd::SsgConfig;
use std::path::PathBuf;
let cfg = SsgConfig::builder()
.content_dir(PathBuf::from("docs"))
.build()
.unwrap();
assert_eq!(cfg.content_dir, PathBuf::from("docs"));Sourcepub fn output_dir(self, dir: PathBuf) -> Self
pub fn output_dir(self, dir: PathBuf) -> Self
Sets the output directory for the configuration.
§Examples
use ssg::cmd::SsgConfig;
use std::path::PathBuf;
let cfg = SsgConfig::builder()
.output_dir(PathBuf::from("dist"))
.build()
.unwrap();
assert_eq!(cfg.output_dir, PathBuf::from("dist"));Sourcepub fn template_dir(self, dir: PathBuf) -> Self
pub fn template_dir(self, dir: PathBuf) -> Self
Sets the template directory for the configuration.
§Examples
use ssg::cmd::SsgConfig;
use std::path::PathBuf;
let cfg = SsgConfig::builder()
.template_dir(PathBuf::from("tpl"))
.build()
.unwrap();
assert_eq!(cfg.template_dir, PathBuf::from("tpl"));Sourcepub fn serve_dir(self, dir: Option<PathBuf>) -> Self
pub fn serve_dir(self, dir: Option<PathBuf>) -> Self
Sets the optional development server directory for the configuration.
§Examples
use ssg::cmd::SsgConfig;
use std::path::PathBuf;
let cfg = SsgConfig::builder()
.serve_dir(Some(PathBuf::from("public")))
.build()
.unwrap();
assert_eq!(cfg.serve_dir, Some(PathBuf::from("public")));Sourcepub fn site_title(self, title: String) -> Self
pub fn site_title(self, title: String) -> Self
Sets the site title for the configuration.
§Examples
use ssg::cmd::SsgConfig;
let cfg = SsgConfig::builder().site_title("Title".into()).build().unwrap();
assert_eq!(cfg.site_title, "Title");Sourcepub fn site_description(self, desc: String) -> Self
pub fn site_description(self, desc: String) -> Self
Sets the site description for the configuration.
§Examples
use ssg::cmd::SsgConfig;
let cfg = SsgConfig::builder().site_description("Demo".into()).build().unwrap();
assert_eq!(cfg.site_description, "Demo");Sourcepub fn language(self, lang: String) -> Self
pub fn language(self, lang: String) -> Self
Sets the language code for the configuration.
§Examples
use ssg::cmd::SsgConfig;
let cfg = SsgConfig::builder().language("fr-FR".into()).build().unwrap();
assert_eq!(cfg.language, "fr-FR");Sourcepub fn i18n(self, i18n: Option<I18nConfig>) -> Self
pub fn i18n(self, i18n: Option<I18nConfig>) -> Self
Sets the i18n configuration.
§Examples
use ssg::cmd::SsgConfig;
let cfg = SsgConfig::builder().i18n(None).build().unwrap();
assert!(cfg.i18n.is_none());Sourcepub fn cdn_prefix(self, prefix: Option<String>) -> Self
pub fn cdn_prefix(self, prefix: Option<String>) -> Self
Sets the CDN prefix configuration.
§Examples
use ssg::cmd::SsgConfig;
let cfg = SsgConfig::builder()
.cdn_prefix(Some("https://cdn.example.com".into()))
.build()
.unwrap();
assert!(cfg.cdn_prefix.is_some());Sourcepub fn og_image(self, og_image: Option<String>) -> Self
pub fn og_image(self, og_image: Option<String>) -> Self
Sets the site-wide fallback og:image used by generated
taxonomy/tag pages that have no per-page image of their own.
§Examples
use ssg::cmd::SsgConfig;
let cfg = SsgConfig::builder()
.og_image(Some("/social/default.png".into()))
.build()
.unwrap();
assert_eq!(cfg.og_image.as_deref(), Some("/social/default.png"));Sourcepub fn edge_headers(self, edge: EdgeHeadersConfig) -> Self
pub fn edge_headers(self, edge: EdgeHeadersConfig) -> Self
Sets the edge-headers emitter configuration (issue #550).
§Examples
use ssg::cmd::{EdgeHeadersConfig, SsgConfig};
let cfg = SsgConfig::builder()
.edge_headers(EdgeHeadersConfig::default())
.build()
.unwrap();
assert!(!cfg.edge_headers.is_enabled());Sourcepub const fn security(self, security: SecurityConfig) -> Self
pub const fn security(self, security: SecurityConfig) -> Self
Sets the security tunables (v0.0.47 plan §3 item 2.3).
§Examples
use ssg::cmd::{SecurityConfig, SriAlgorithm, SsgConfig};
let cfg = SsgConfig::builder()
.security(SecurityConfig {
sri_algorithm: SriAlgorithm::Sha512,
})
.build()
.unwrap();
assert_eq!(cfg.security.sri_algorithm, SriAlgorithm::Sha512);Sourcepub const fn transitions(self, enabled: bool) -> Self
pub const fn transitions(self, enabled: bool) -> Self
Enables the View Transitions + lazy-nav client (issue #547).
§Examples
use ssg::cmd::SsgConfig;
let cfg = SsgConfig::builder().transitions(true).build().unwrap();
assert!(cfg.transitions);Sourcepub fn build(self) -> Result<SsgConfig, CliError>
pub fn build(self) -> Result<SsgConfig, CliError>
Builds the final SsgConfig instance.
§Examples
use ssg::cmd::SsgConfig;
let cfg = SsgConfig::builder().build().expect("default is valid");
assert!(!cfg.site_name.is_empty());§Errors
Returns CliError::ValidationError when SsgConfig::validate fails.
Trait Implementations§
Source§impl Clone for SsgConfigBuilder
impl Clone for SsgConfigBuilder
Source§fn clone(&self) -> SsgConfigBuilder
fn clone(&self) -> SsgConfigBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SsgConfigBuilder
impl Debug for SsgConfigBuilder
Source§impl Default for SsgConfigBuilder
impl Default for SsgConfigBuilder
Source§fn default() -> SsgConfigBuilder
fn default() -> SsgConfigBuilder
Auto Trait Implementations§
impl Freeze for SsgConfigBuilder
impl RefUnwindSafe for SsgConfigBuilder
impl Send for SsgConfigBuilder
impl Sync for SsgConfigBuilder
impl Unpin for SsgConfigBuilder
impl UnsafeUnpin for SsgConfigBuilder
impl UnwindSafe for SsgConfigBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more