Add the description to group pages.

This commit is contained in:
Bauke 2023-06-09 12:53:37 +02:00
parent be1c403112
commit af3b0b3c26
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
4 changed files with 22 additions and 3 deletions

View File

@ -118,7 +118,7 @@ pub async fn run() -> Result<()> {
.render(&output, &group.name, true)
.await?;
GroupTemplate::new(&group.name)
GroupTemplate::new(group.description.clone(), &group.name)
.await
.render_to_file(&output)
.await?;

View File

@ -26,6 +26,7 @@ a:visited {
}
}
blockquote,
h1,
h2,
h3,
@ -36,6 +37,13 @@ li {
padding: 0;
}
blockquote {
background-color: var(--background-2);
border-left: 2px solid var(--foreground-1);
margin-bottom: var(--medium-spacing);
padding: var(--medium-spacing);
}
details {
border: 1px dashed var(--foreground-1);

View File

@ -13,6 +13,10 @@
<main class="page-main">
<h2>General</h2>
{% if let Some(description) = group_description %}
<blockquote>{{ description }}</blockquote>
{% endif %}
<img class="chart" src="/charts/user-count/{{ group_name }}.svg"
alt="{{ group_name }} User Count Chart">
</main>

View File

@ -86,7 +86,10 @@ pub struct GroupTemplate {
/// Extra HTML to insert in the head.
pub extra_head_html: String,
/// The group name for this group.
/// The description for this group.
pub group_description: Option<String>,
/// The name for this group.
pub group_name: String,
/// The string for the `<title>` element.
@ -98,7 +101,10 @@ pub struct GroupTemplate {
impl GroupTemplate {
/// Create a new [`GroupTemplate`].
pub async fn new(group_name: &str) -> Self {
pub async fn new(
group_description: Option<String>,
group_name: &str,
) -> Self {
let extra_body_html = read_to_string("extra-body.html").await;
let extra_head_html = read_to_string("extra-head.html").await;
@ -106,6 +112,7 @@ impl GroupTemplate {
base_url: get_base_url(),
extra_body_html: extra_body_html.unwrap_or_default(),
extra_head_html: extra_head_html.unwrap_or_default(),
group_description,
group_name: group_name.to_string(),
page_title: "Tildes Statistics".to_string(),
today: today(),