use the cwd as site title

This commit is contained in:
la Fleur 2020-11-11 02:07:21 +01:00
parent 980d02a946
commit cbdfe627b8
1 changed files with 5 additions and 2 deletions

View File

@ -42,7 +42,7 @@ fn list_contents() -> io::Result<Vec<String>> {
#[derive(serde::Serialize)] #[derive(serde::Serialize)]
struct IndexContext { struct IndexContext {
name: &'static str, title: String,
items: Vec<String> items: Vec<String>
} }
@ -63,8 +63,11 @@ fn show(content: Content) -> Template {
#[get("/")] #[get("/")]
fn index() -> io::Result<Template> { fn index() -> io::Result<Template> {
let context = IndexContext { name: "home", items: users }; let cwd = std::env::current_dir()?;
let title = String::from(cwd.to_str().unwrap().split("/").last().unwrap());
//println!("{}", title);
let contents = list_contents()?; let contents = list_contents()?;
let context = IndexContext { title: title, items: contents };
Ok(Template::render("index", &context)) Ok(Template::render("index", &context))
} }