summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.rs8
-rw-r--r--src/works/mod.rs3
-rw-r--r--src/works/stories.rs10
3 files changed, 17 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index 942b621..871c57e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -15,9 +15,11 @@ fn main() -> Result<()> {
std::fs::write("docs/index.html", output)?;
// render stories.html file
- let stories = works::stories::Stories::new_from_file(std::fs::File::open(
- std::path::PathBuf::from("stories.json"),
+ let stories = std::rc::Rc::new(works::stories::Stories::new_from_file(
+ std::fs::File::open(std::path::PathBuf::from("stories.json"))?,
)?);
- stories?.render_overview_page(&tera, "stories")?;
+ std::rc::Rc::clone(&stories).render_overview_page(&tera, "stories")?;
+ std::rc::Rc::clone(&stories).render_single_pages(&tera, "story")?;
+
Ok(())
}
diff --git a/src/works/mod.rs b/src/works/mod.rs
index 6cb9331..1d0b3de 100644
--- a/src/works/mod.rs
+++ b/src/works/mod.rs
@@ -21,6 +21,9 @@ pub trait Works: for<'a> Deserialize<'a> + Serialize {
Ok(context)
}
+ // render page for every work
+ fn render_single_pages(&self, tera_instance: &tera::Tera, template_name: &str) -> Result<()>;
+
// render corresponding overview HTML template
// with its tera context
fn render_overview_page(
diff --git a/src/works/stories.rs b/src/works/stories.rs
index 4620553..c68745a 100644
--- a/src/works/stories.rs
+++ b/src/works/stories.rs
@@ -18,7 +18,15 @@ pub struct Story {
}
// see src/works/mod.rs for information of Works trait
-impl super::Works for Stories {}
+impl super::Works for Stories {
+ fn render_single_pages(
+ &self,
+ tera_instance: &tera::Tera,
+ template_name: &str,
+ ) -> anyhow::Result<()> {
+ !unimplemented!()
+ }
+}
// language of story content
#[derive(Deserialize, Serialize, Debug)]