More tweaks

This commit is contained in:
Shadowfacts 2025-02-11 20:45:53 -05:00
parent 6f6e1453f7
commit 593ed74eb7
6 changed files with 44 additions and 10 deletions

View File

@ -7,10 +7,10 @@
{% block content -%}
{% for year in years %}
<h2>{{ year }}</h2>
<ul>
<ul class="archive-list">
{% for entry in posts_by_year[year] %}
<li>
<code><time datetime="{{ entry.date | iso_datetime }}">{{ entry.date | iso_date }}</time></code>
<a href="{{ entry.permalink }}">
{{ entry.title }}
</a>

View File

@ -115,6 +115,10 @@ table {
}
}
hr {
border: 1px solid black;
}
html {
font-family: "Valkyrie A", Charter, serif;
font-size: 16px;
@ -360,9 +364,29 @@ footer {
left: 0;
background: var(--webring-gradient);
}
&:hover::after {
height: 3px;
bottom: 1px;
}
a {
color: transparent;
text-decoration: none;
position: relative;
}
}
.archive-list {
padding: 0;
font-size: 1.5rem;
li {
list-style: none;
time {
color: var(--secondary-text-color);
}
&:hover time {
color: var(--text-color);
}
}
}

View File

@ -9,10 +9,10 @@
<h1>Posts tagged &lsquo;{{ tag_name }}&rsquo;</h1>
{% for year in years %}
<h2>{{ year }}</h2>
<ul>
<ul class="archive-list">
{% for entry in posts_by_year[year] %}
<li>
<code><time datetime="{{ entry.date | iso_datetime }}">{{ entry.date | iso_date }}</time></code>
<a href="{{ entry.permalink }}">
{{ entry.title }}
</a>

View File

@ -1,6 +1,6 @@
use std::collections::HashMap;
use chrono::Datelike;
use chrono::{DateTime, Datelike, FixedOffset};
use compute_graph::{
builder::GraphBuilder,
input::{Input, InputVisitable},
@ -62,7 +62,7 @@ impl Rule for Entries {
.map(|post| Entry {
permalink: post.permalink(),
title: post.metadata.title.clone(),
year: post.metadata.date.year(),
date: post.metadata.date,
})
.collect()
}
@ -75,7 +75,7 @@ impl Rule for PostsByYear {
fn evaluate(&mut self) -> Self::Output {
let mut map = HashMap::new();
for entry in self.input_0().iter().cloned() {
map.entry(entry.year).or_insert(vec![]).push(entry);
map.entry(entry.date.year()).or_insert(vec![]).push(entry);
}
PostsYearMap(map)
}
@ -97,5 +97,5 @@ impl PostsYearMap {
pub struct Entry {
pub permalink: String,
pub title: String,
pub year: i32,
pub date: DateTime<FixedOffset>,
}

View File

@ -1,6 +1,5 @@
use std::collections::HashMap;
use chrono::Datelike;
use compute_graph::{
builder::GraphBuilder,
input::{DynamicInput, Input, InputVisitable},
@ -127,7 +126,7 @@ impl Rule for PostsByTag {
Some(Entry {
permalink: post.permalink(),
title: post.metadata.title.clone(),
year: post.metadata.date.year(),
date: post.metadata.date,
})
} else {
None

View File

@ -26,6 +26,7 @@ pub fn make_graph(
) -> Input<Templates> {
let mut empty_templates = Templates::default();
empty_templates.register_filter("iso_datetime", filters::iso_datetime);
empty_templates.register_filter("iso_date", filters::iso_date);
empty_templates.register_filter("pretty_date", filters::pretty_date);
empty_templates.register_filter("pretty_datetime", filters::pretty_datetime);
empty_templates.register_filter("reading_time", filters::reading_time);
@ -272,6 +273,16 @@ pub mod filters {
Ok(Value::String(date.format("%+:0").to_string()))
}
pub fn iso_date(value: &Value, _args: &HashMap<String, Value>) -> Result<Value> {
let date = DateTime::<Local>::deserialize(value)?;
Ok(Value::String(format!(
"{}-{:0>2}-{:0>2}",
date.year(),
date.month(),
date.day()
)))
}
const MONTHS: &[&str; 12] = &[
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
];