implement semantic meta titles

This commit is contained in:
yggverse 2025-08-10 09:43:40 +03:00
parent b53a6cf8ca
commit ee494dbfd8
2 changed files with 24 additions and 1 deletions

View file

@ -50,6 +50,18 @@ fn index(
Ok(Template::render(
"index",
context! {
title: {
let mut t = meta.title.clone();
if let Some(ref description) = meta.description {
t.push_str(S);
t.push_str(description)
}
if let Some(p) = page {
t.push_str(S);
t.push_str(&format!("Page {p}"));
}
t
},
meta: meta.inner(),
back: page.map(|p| uri!(index(if p > 2 { Some(p - 1) } else { None }))),
next: if page.unwrap_or(1) * public.default_limit >= total { None }
@ -105,6 +117,15 @@ fn info(
Ok(Template::render(
"info",
context! {
title: {
let mut t = String::new();
if let Some(ref name) = torrent.name {
t.push_str(name);
t.push_str(S)
}
t.push_str(&meta.title);
t
},
meta: meta.inner(),
created: torrent.creation_date.map(|t| t.format(&meta.format_time).to_string()),
files_total: torrent.files(),
@ -219,3 +240,5 @@ fn rocket() -> _ {
.mount("/", rocket::fs::FileServer::from(config.public))
.mount("/", routes![index, rss, info])
}
const S: &str = " - ";

View file

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="UTF-8" />
<title>{{ meta.title }}</title>
<title>{{ title }}</title>
{% if meta.description %}
<meta name="description" content="{{ meta.description }}" />
{% endif %}