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

View File

@ -115,6 +115,10 @@ table {
} }
} }
hr {
border: 1px solid black;
}
html { html {
font-family: "Valkyrie A", Charter, serif; font-family: "Valkyrie A", Charter, serif;
font-size: 16px; font-size: 16px;
@ -360,9 +364,29 @@ footer {
left: 0; left: 0;
background: var(--webring-gradient); background: var(--webring-gradient);
} }
&:hover::after {
height: 3px;
bottom: 1px;
}
a { a {
color: transparent; color: transparent;
text-decoration: none; text-decoration: none;
position: relative; 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> <h1>Posts tagged &lsquo;{{ tag_name }}&rsquo;</h1>
{% for year in years %} {% for year in years %}
<h2>{{ year }}</h2> <ul class="archive-list">
<ul>
{% for entry in posts_by_year[year] %} {% for entry in posts_by_year[year] %}
<li> <li>
<code><time datetime="{{ entry.date | iso_datetime }}">{{ entry.date | iso_date }}</time></code>
<a href="{{ entry.permalink }}"> <a href="{{ entry.permalink }}">
{{ entry.title }} {{ entry.title }}
</a> </a>

View File

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

View File

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

View File

@ -26,6 +26,7 @@ pub fn make_graph(
) -> Input<Templates> { ) -> Input<Templates> {
let mut empty_templates = Templates::default(); let mut empty_templates = Templates::default();
empty_templates.register_filter("iso_datetime", filters::iso_datetime); 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_date", filters::pretty_date);
empty_templates.register_filter("pretty_datetime", filters::pretty_datetime); empty_templates.register_filter("pretty_datetime", filters::pretty_datetime);
empty_templates.register_filter("reading_time", filters::reading_time); empty_templates.register_filter("reading_time", filters::reading_time);
@ -272,6 +273,16 @@ pub mod filters {
Ok(Value::String(date.format("%+:0").to_string())) 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] = &[ const MONTHS: &[&str; 12] = &[
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
]; ];