use the cwd as site title
This commit is contained in:
parent
980d02a946
commit
cbdfe627b8
|
@ -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))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue