summaryrefslogtreecommitdiff
path: root/src/works/stories.rs
blob: 450f3bcd3ef4ee21f0be8e215f04f8b9600fe517 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use serde::{Deserialize, Serialize};

#[derive(Debug, Deserialize)]
pub struct Stories(pub Vec<Story>);

#[derive(Debug, Deserialize, Serialize)]
pub struct Story {
    pub id: u8,
    pub title: String,
    pub description: String,
    pub path_to_document: String,
    pub slug: String,
    pub language: Language,
}

impl super::Works for Stories {
    fn create_tera_context(&self) -> tera::Context {
        let mut context = tera::Context::new();
        for story in self.0.iter() {
            context.insert(format!("story-{}", story.id), &story);
        }
        context
    }
}

#[derive(Deserialize, Serialize, Debug)]
pub enum Language {
    German,
    English,
}