Add before/after navbar/content and make navbar not render when needed

This commit is contained in:
Sofia 2018-04-16 18:22:13 +03:00
parent fe3a74a1c1
commit 933189b7b2
6 changed files with 32 additions and 12 deletions

View File

@ -4,18 +4,25 @@ built_pages = ["test_page/about.toml", "test_page/other.toml"]
use_default_css = true
javascript = []
css = []
#before_navbar_url = "/navbar.html"
#before_content_url = "/before_content.html"
#after_content_url = "/after_content.html"
#favicon = "favicon.png"
#twitter_author = "@teascade"
#google_robots = "all"
#google_site_verification = ""
[navbar]
items = ["about", "other"]
#[navbar]
#items = ["about", "other", "google"]
[navbar.item.about]
title = "About"
link = "/"
# [navbar.item.about]
# title = "About"
# link = "/"
[navbar.item.other]
title = "Other"
link = "/other"
# [navbar.item.other]
# title = "Other"
# link = "/other"
# [navbar.item.google]
# title = "Google!"
# link = "https://google.com"

View File

@ -2,7 +2,7 @@ use toml;
use std::path::PathBuf;
use std::fs::File;
use std::io::{Error as IOError, ErrorKind, Read};
use std::io::Read;
use std::error::Error as STDError;
use std::collections::HashMap;
@ -23,6 +23,9 @@ pub struct WebsiteConfig {
pub javascript: Vec<String>,
pub css: Vec<String>,
pub favicon: Option<String>,
pub before_navbar_url: Option<String>,
pub before_content_url: Option<String>,
pub after_content_url: Option<String>,
pub twitter_author: Option<String>,
pub google_robots: Option<String>,
pub google_site_verification: Option<String>,
@ -122,6 +125,9 @@ pub struct PageConfig {
pub description: String,
pub content_path: String,
pub favicon: Option<String>,
pub before_navbar_url: Option<String>,
pub before_content_url: Option<String>,
pub after_content_url: Option<String>,
pub javascript: Option<Vec<String>>,
pub css: Option<Vec<String>>,
}

View File

@ -110,7 +110,7 @@ impl Template {
"twitter_author".to_owned() => twitter_author,
"use_default_css".to_owned() => config.global_config.website.use_default_css.to_string(),
"navbar".to_owned() => "true".to_owned(),
"navbar".to_owned() => config.global_config.navbar.is_some().to_string(),
"navbar_content".to_owned() => navbar_content,
"content".to_owned() => content

View File

@ -33,16 +33,17 @@
</head>
<body>
{{if navbar}}
{{before_navbar}} {{if navbar}}
<nav>
<ul>
{{navbar_content}}
</ul>
</nav>
{{endif}}
{{endif}} {{before_content}}
<article>
{{content}}
</article>
{{after_content}}
</body>
</html>

View File

@ -4,5 +4,8 @@ title = "About"
description = "This is the test About page"
content_path = "about.md"
favicon = "/favicon.png"
#before_navbar_url = "/navbar.html"
#before_content_url = "/before_content.html"
#after_content_url = "/after_content.html"
#javascript = ["Additional JavaScript"]
#css = ["Additional CSS"]

View File

@ -4,5 +4,8 @@ title = "Other!"
description = "This is the .. other page"
content_path = "other.md"
#favicon = "optional_favicon.png"
#before_navbar_url = "/navbar.html"
#before_content_url = "/before_content.html"
#after_content_url = "/after_content.html"
#javascript = ["Additional JavaScript"]
#css = ["Additional CSS"]