frontmatter_gen::config

Struct Config

Source
pub struct Config {
    pub site_name: String,
    pub site_title: String,
    pub site_description: String,
    pub language: String,
    pub base_url: String,
    pub content_dir: PathBuf,
    pub output_dir: PathBuf,
    pub template_dir: PathBuf,
    pub serve_dir: Option<PathBuf>,
    pub server_enabled: bool,
    pub server_port: u16,
    /* private fields */
}
Expand description

Core configuration structure.

This structure defines the configuration options for the Static Site Generator.

Fields§

§site_name: String

Name of the site.

§site_title: String

Title of the site, displayed in the browser’s title bar.

§site_description: String

Description of the site.

§language: String

Language of the site (e.g., “en” for English).

§base_url: String

Base URL of the site.

§content_dir: PathBuf

Path to the directory containing content files.

§output_dir: PathBuf

Path to the directory where the generated output will be stored.

§template_dir: PathBuf

Path to the directory containing templates.

§serve_dir: Option<PathBuf>

Optional directory to serve during development.

§server_enabled: bool

Flag to enable or disable the development server.

§server_port: u16

Port for the development server.

Implementations§

Source§

impl Config

Source

pub fn builder() -> Builder

Creates a new Builder instance for fluent configuration creation

§Examples

Basic usage (always available):

use frontmatter_gen::config::Config;

let config = Config::builder()
    .site_name("My Site")
    .build()
    .unwrap();

With SSG features (requires “ssg” feature):

use frontmatter_gen::config::Config;

let config = Config::builder()
    .site_name("My Site")
    .content_dir("content")  // Only available with "ssg" feature
    .template_dir("templates")  // Only available with "ssg" feature
    .build()
    .unwrap();
Source

pub fn from_file(path: &Path) -> Result<Self>

Loads configuration from a TOML file

§Arguments
  • path - Path to the TOML configuration file
§Returns

Returns a Result containing the loaded Config or an error

§Errors

Will return an error if:

  • File cannot be read
  • TOML parsing fails
  • Configuration validation fails
§Examples
use frontmatter_gen::config::Config;
use std::path::Path;

let config = Config::from_file(Path::new("config.toml")).unwrap();
Source

pub fn validate(&self) -> Result<()>

Validates the configuration settings

§Returns

Returns Ok(()) if validation passes, or an error if validation fails

§Errors

Will return an error if:

  • Required fields are empty
  • Paths are invalid or unsafe
  • URLs are malformed
  • Language code format is invalid
Source

pub const fn id(&self) -> Uuid

Gets the unique identifier for this configuration

Source

pub fn site_name(&self) -> &str

Gets the site name

Source

pub const fn server_enabled(&self) -> bool

Gets whether the development server is enabled

Source

pub const fn server_port(&self) -> Option<u16>

Gets the server port if the server is enabled

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Config

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Serialize for Config

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T