Replace the hardcoded title in the template by the one in the config
This commit is contained in:
parent
fdcb4f3799
commit
95094a7d50
2 changed files with 6 additions and 3 deletions
|
@ -1,16 +1,18 @@
|
|||
use rocket::State;
|
||||
use rocket_contrib::Template;
|
||||
use std::collections::HashMap;
|
||||
use super::super::Config;
|
||||
use super::super::NoteStore;
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct IndexTemplateContext<'a> {
|
||||
app_version: &'a str,
|
||||
notes: Vec<HashMap<&'a str, &'a str>>,
|
||||
title: String,
|
||||
}
|
||||
|
||||
#[get("/")]
|
||||
fn index(notes: State<NoteStore>) -> Template {
|
||||
fn index(notes: State<NoteStore>, config: State<Config>) -> Template {
|
||||
let notes = notes.read().unwrap();
|
||||
let mut note_kvs = vec![];
|
||||
for note in notes.iter() {
|
||||
|
@ -22,6 +24,7 @@ fn index(notes: State<NoteStore>) -> Template {
|
|||
let context = IndexTemplateContext {
|
||||
app_version: env!("CARGO_PKG_VERSION"),
|
||||
notes: note_kvs,
|
||||
title: config.title.clone(),
|
||||
};
|
||||
Template::render("index", &context)
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{% block title %}Online Prikbord Familie van Tilburg{% endblock title %}</title>
|
||||
<title>{% block title %}{{ title }}{% endblock title %}</title>
|
||||
|
||||
<!-- Favicons -->
|
||||
<link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
|
||||
|
@ -34,7 +34,7 @@
|
|||
{% block body %}
|
||||
<nav class="navbar navbar-expand-md fixed-top navbar-dark bg-dark text-light" role="navigation">
|
||||
<div class="container">
|
||||
<a class="navbar-brand note-select" href="#">Online Prikbord</a>
|
||||
<a class="navbar-brand note-select" href="#">{{ title }}</a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
|
Loading…
Reference in a new issue