37 lines
762 B
Rust
37 lines
762 B
Rust
use serde::Serialize;
|
|
use std::{collections::HashSet, path::PathBuf};
|
|
|
|
use crate::config::Config;
|
|
|
|
#[derive(Serialize, Default, Clone)]
|
|
pub struct Article {
|
|
pub title: String,
|
|
pub date: String,
|
|
pub author: String,
|
|
pub slug: String,
|
|
pub file_path: PathBuf,
|
|
pub tags: HashSet<String>,
|
|
}
|
|
|
|
impl Article {
|
|
pub fn get_build_path(&self, config: &Config) -> PathBuf {
|
|
config
|
|
.get_build_path()
|
|
.join("articles")
|
|
.join(&self.slug)
|
|
.join("index.html")
|
|
}
|
|
}
|
|
|
|
#[derive(Serialize, Default)]
|
|
pub struct ArticleContext {
|
|
article: Article,
|
|
content: String,
|
|
}
|
|
|
|
impl ArticleContext {
|
|
pub fn new(article: Article, content: String) -> Self {
|
|
Self { article, content }
|
|
}
|
|
}
|