Skip to content

Commit

Permalink
feat: Default for LeptosOptions, ConfFile (#2208)
Browse files Browse the repository at this point in the history
Co-authored-by: chrisp60 <[email protected]>
  • Loading branch information
chrisp60 and chrisp60 authored Jan 21, 2024
1 parent b450f0f commit d33e57d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions leptos_config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use typed_builder::TypedBuilder;

/// A Struct to allow us to parse LeptosOptions from the file. Not really needed, most interactions should
/// occur with LeptosOptions
#[derive(Clone, Debug, serde::Deserialize)]
#[derive(Clone, Debug, serde::Deserialize, Default)]
#[serde(rename_all = "kebab-case")]
pub struct ConfFile {
pub leptos_options: LeptosOptions,
Expand All @@ -27,7 +27,7 @@ pub struct ConfFile {
#[serde(rename_all = "kebab-case")]
pub struct LeptosOptions {
/// The name of the WASM and JS files generated by wasm-bindgen. Defaults to the crate name with underscores instead of dashes
#[builder(setter(into))]
#[builder(setter(into), default=default_output_name())]
pub output_name: String,
/// The path of the all the files generated by cargo-leptos. This defaults to '.' for convenience when integrating with other
/// tools.
Expand Down Expand Up @@ -112,6 +112,16 @@ impl LeptosOptions {
}
}

impl Default for LeptosOptions {
fn default() -> Self {
LeptosOptions::builder().build()
}
}

fn default_output_name() -> String {
env!("CARGO_CRATE_NAME").replace('-', "_")
}

fn default_site_root() -> String {
".".to_string()
}
Expand Down

0 comments on commit d33e57d

Please sign in to comment.