diff --git a/src/blog/mod.rs b/src/blog/mod.rs new file mode 100644 index 0000000..c921710 --- /dev/null +++ b/src/blog/mod.rs @@ -0,0 +1,2 @@ +pub mod structs; +pub use structs::{BlogConfig}; \ No newline at end of file diff --git a/src/blog/structs.rs b/src/blog/structs.rs new file mode 100644 index 0000000..a42363d --- /dev/null +++ b/src/blog/structs.rs @@ -0,0 +1,6 @@ +use serde::{Serialize, Deserialize}; + +#[derive(Serialize, Deserialize, Debug, PartialEq)] +pub struct BlogConfig { + source: String, +} \ No newline at end of file diff --git a/src/links/mod.rs b/src/links/mod.rs index 2637256..c6902f1 100644 --- a/src/links/mod.rs +++ b/src/links/mod.rs @@ -1,56 +1,12 @@ -use serde::{Serialize, Deserialize}; +pub mod structs; +pub use structs::{LinksConfig, RustyLinks, MetaData}; + use chrono::{DateTime, Utc}; use serde_yaml::{self}; use minijinja::Environment; use std::path::PathBuf; use crate::file_utils::{write_file, copy_recursively}; - - -#[derive(Serialize, Deserialize, Debug, PartialEq)] -pub struct LinksConfig { - pub source: String, - pub template: String, - pub static_dir: String, -} -#[derive(Serialize, Deserialize, Debug)] -struct RustyLinks { - config: Config, - links: Vec, - pub metadata: Option, -} - -#[derive(Serialize, Deserialize, Debug)] -struct MetaData { - pub last_updated: String, -} - -#[derive(Serialize, Deserialize, Debug)] -struct Config { - title: String, - name: String, - description: String, - avatar: String, - background: String, - background_opacity: f64, -} - -#[derive(Serialize, Deserialize, Debug)] -struct Links { - title: String, - links: Vec, -} - -#[derive(Serialize, Deserialize, Debug)] -struct Link { - text: String, - icon: String, - href: Option, - copy: Option, - rels: Option, -} - - fn load_links(config: &LinksConfig) -> RustyLinks { let links_yaml = std::fs::File::open(&config.source).expect(&format!("Could not find {}", config.source)); diff --git a/src/links/structs.rs b/src/links/structs.rs new file mode 100644 index 0000000..935d349 --- /dev/null +++ b/src/links/structs.rs @@ -0,0 +1,45 @@ +use serde::{Serialize, Deserialize}; + +#[derive(Serialize, Deserialize, Debug)] +struct Links { + title: String, + links: Vec, +} + +#[derive(Serialize, Deserialize, Debug)] +struct Link { + text: String, + icon: String, + href: Option, + copy: Option, + rels: Option, +} + + +#[derive(Serialize, Deserialize, Debug, PartialEq)] +pub struct LinksConfig { + pub source: String, + pub template: String, + pub static_dir: String, +} +#[derive(Serialize, Deserialize, Debug)] +pub struct RustyLinks { + config: Config, + links: Vec, + pub metadata: Option, +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct MetaData { + pub last_updated: String, +} + +#[derive(Serialize, Deserialize, Debug)] +struct Config { + title: String, + name: String, + description: String, + avatar: String, + background: String, + background_opacity: f64, +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index e64b6d6..8270715 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,16 +1,13 @@ mod links; mod file_utils; +mod blog; use crate::links::{LinksConfig, create_links}; +use crate::blog::{BlogConfig}; use serde::{Serialize, Deserialize}; use std::path::PathBuf; -#[derive(Serialize, Deserialize, Debug, PartialEq)] -pub struct BlogConfig { - source: String, -} - #[derive(Serialize, Deserialize, Debug, Default)] pub struct Config { output_dir: String,