added short post description for embeds
This commit is contained in:
parent
9521674ba1
commit
1fd3bdd49f
2 changed files with 8 additions and 3 deletions
|
@ -29,6 +29,7 @@ pub const BLOG: &str = r#"
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta property="og:title" content="{{ sitetitle }}" />
|
<meta property="og:title" content="{{ sitetitle }}" />
|
||||||
|
<meta property="og:description" content="{{ sitedescription }}" />
|
||||||
<meta property="og:image" content="/static/site-image.png" />
|
<meta property="og:image" content="/static/site-image.png" />
|
||||||
|
|
||||||
<title> {{ sitetitle }} </title>
|
<title> {{ sitetitle }} </title>
|
||||||
|
|
|
@ -63,11 +63,13 @@ async fn root() -> impl Responder {
|
||||||
#[get("/blog")]
|
#[get("/blog")]
|
||||||
async fn blog() -> impl Responder {
|
async fn blog() -> impl Responder {
|
||||||
let posts = db::get_last_five_posts();
|
let posts = db::get_last_five_posts();
|
||||||
|
let username = config::get_from_env("USERNAME", true);
|
||||||
|
|
||||||
let mut context = Context::new();
|
let mut context = Context::new();
|
||||||
context.insert("posts", &posts);
|
context.insert("posts", &posts);
|
||||||
context.insert("username", &(config::get_from_env("USERNAME", true)));
|
context.insert("username", &username);
|
||||||
context.insert("sitetitle", &(config::get_from_env("USERNAME", true) + "' blog"));
|
context.insert("sitetitle", &format!("{}' blog'", &username));
|
||||||
|
context.insert("sitedescription", &format!("Last 5 posts of {}' blog'", &username));
|
||||||
|
|
||||||
// one-off render blog template with context
|
// one-off render blog template with context
|
||||||
let result = Tera::one_off(
|
let result = Tera::one_off(
|
||||||
|
@ -85,11 +87,13 @@ async fn blog_by_id(web::Path(post_id): web::Path<std::string::String>) -> impl
|
||||||
let (valid, id) = id_valid(post_id);
|
let (valid, id) = id_valid(post_id);
|
||||||
if valid {
|
if valid {
|
||||||
let post = db::get_post_by_id(id as i32);
|
let post = db::get_post_by_id(id as i32);
|
||||||
|
let username = config::get_from_env("USERNAME", true);
|
||||||
|
|
||||||
let mut context = Context::new();
|
let mut context = Context::new();
|
||||||
context.insert("posts", &[&post]);
|
context.insert("posts", &[&post]);
|
||||||
context.insert("username", &(config::get_from_env("USERNAME", true)));
|
context.insert("username", &username);
|
||||||
context.insert("sitetitle", &post.title);
|
context.insert("sitetitle", &post.title);
|
||||||
|
context.insert("sitedescription", &format!("Last 5 posts of {}' blog'", &username));
|
||||||
|
|
||||||
// one-off render blog template with context
|
// one-off render blog template with context
|
||||||
let result = Tera::one_off(
|
let result = Tera::one_off(
|
||||||
|
|
Loading…
Reference in a new issue