diff options
author | Thomas Letan <lthms@soap.coffee> | 2020-11-17 11:51:41 +0100 |
---|---|---|
committer | Thomas Letan <lthms@soap.coffee> | 2020-11-17 11:51:41 +0100 |
commit | cc0f7ff111eeba92eb7d6d917af0655d29d92cc5 (patch) | |
tree | 3131d994ceaa6d61346ab1783220e2eb6bb09365 | |
parent | Use ogmarkup from crates and bump version number (diff) |
Add a description field in Book.toml schema
-rw-r--r-- | app/src/filesystem.rs | 1 | ||||
-rw-r--r-- | lib/src/project.rs | 3 | ||||
-rw-r--r-- | lib/src/wstatic.rs | 5 |
3 files changed, 7 insertions, 2 deletions
diff --git a/app/src/filesystem.rs b/app/src/filesystem.rs index 1ce55fd..758282a 100644 --- a/app/src/filesystem.rs +++ b/app/src/filesystem.rs @@ -51,6 +51,7 @@ fn canonicalize_project( Ok(Project { author : project.author, title : project.title, + description : project.description, cover : project .cover .map(canonicalize) diff --git a/lib/src/project.rs b/lib/src/project.rs index 0a00ab2..1ba9498 100644 --- a/lib/src/project.rs +++ b/lib/src/project.rs @@ -77,6 +77,7 @@ impl<I> Chapter<Vec<I>> { pub struct Project<C, I> { pub author : String, pub title : String, + pub description : Option<String>, pub chapters : Vec<Chapter<I>>, pub cover : Option<C>, pub numbering : Option<bool>, @@ -96,6 +97,7 @@ impl Project<Cover, String> { let lang = project.language; let typo = lang.typography(); let numbering = project.numbering; + let descr = project.description; let author = project.author; let title = project.title; let cover = project @@ -111,6 +113,7 @@ impl Project<Cover, String> { .map(|x| Project { author : author, title : title, + description : descr, chapters : x, cover : cover, numbering : numbering, diff --git a/lib/src/wstatic.rs b/lib/src/wstatic.rs index a957f85..43f61be 100644 --- a/lib/src/wstatic.rs +++ b/lib/src/wstatic.rs @@ -72,6 +72,7 @@ impl Static { ctx.insert("language", &project.language); ctx.insert("title", &project.title); ctx.insert("body_only", &self.body_only); + ctx.insert("description", &project.description); self.write_template( &PathBuf::from("index.html"), @@ -98,9 +99,9 @@ impl Static { .map(|(idx, c)| { let mut ctx = Context::new(); ctx.insert("number", &(idx + 1)); - ctx.insert("chapter", &c); + ctx.insert("chapter", c); ctx.insert("numbering", &numbering); - ctx.insert("language", &lang); + ctx.insert("language", lang); ctx.insert("body_only", &self.body_only); ctx.insert("chapters_number", &max); |