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
impl Config
Sourcepub fn builder() -> Builder
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();
Sourcepub fn from_file(path: &Path) -> Result<Self>
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();
Sourcepub const fn server_enabled(&self) -> bool
pub const fn server_enabled(&self) -> bool
Gets whether the development server is enabled
Sourcepub const fn server_port(&self) -> Option<u16>
pub const fn server_port(&self) -> Option<u16>
Gets the server port if the server is enabled