Author: Manos Pitsidianakis [manos@pitsidianak.is]
Hash: 69153fde3cfc1b87bfb10144ef7d0b593a1169e4
Timestamp: Mon, 08 May 2023 07:59:41 +0000 (1 year ago)

+5 -1 +/-2 browse
web: add rel="canonical" urls for lists
1diff --git a/web/src/lists.rs b/web/src/lists.rs
2index f148ab4..84dee4d 100644
3--- a/web/src/lists.rs
4+++ b/web/src/lists.rs
5 @@ -120,6 +120,7 @@ pub async fn list(
6 let context = minijinja::context! {
7 site_title => state.site_title.as_ref(),
8 site_subtitle => state.site_subtitle.as_ref(),
9+ canonical_url => ListPath::from(&list).to_crumb(),
10 page_title => &list.name,
11 description => &list.description,
12 post_policy => &post_policy,
13 @@ -200,6 +201,7 @@ pub async fn list_post(
14 let context = minijinja::context! {
15 site_title => state.site_title.as_ref(),
16 site_subtitle => state.site_subtitle.as_ref(),
17+ canonical_url => ListPostPath(ListPathIdentifier::from(list.id.clone()), msg_id.to_string()).to_crumb(),
18 page_title => subject_ref,
19 description => &list.description,
20 list => Value::from_object(MailingList::from(list)),
21 @@ -302,6 +304,7 @@ pub async fn list_edit(
22 let context = minijinja::context! {
23 site_title => state.site_title.as_ref(),
24 site_subtitle => state.site_subtitle.as_ref(),
25+ canonical_url => ListEditPath(ListPathIdentifier::from(list.id.clone())).to_crumb(),
26 page_title => format!("Edit {} settings", list.name),
27 description => &list.description,
28 post_policy => &post_policy,
29 diff --git a/web/src/templates/header.html b/web/src/templates/header.html
30index 9cbafa0..6c293cc 100644
31--- a/web/src/templates/header.html
32+++ b/web/src/templates/header.html
33 @@ -3,7 +3,8 @@
34 <head>
35 <meta charset="utf-8">
36 <meta name="viewport" content="width=device-width, initial-scale=1">
37- <title>{{ title }}</title>
38+ <title>{{ title if title else page_title if page_title else site_title }}</title>{% if canonical_url %}
39+ <link href="{{ root_url_prefix }}{{ canonical_url | safe }}" rel="canonical" />{% endif %}
40 {% include "css.html" %}
41 </head>
42 <body>