aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--code/src/atom.rs4
-rw-r--r--code/src/html.rs31
-rw-r--r--code/src/main.rs4
3 files changed, 24 insertions, 15 deletions
diff --git a/code/src/atom.rs b/code/src/atom.rs
index ce6aa6e..0b3b5ba 100644
--- a/code/src/atom.rs
+++ b/code/src/atom.rs
@@ -8,7 +8,7 @@ pub fn generate_atom(args: &Args) -> String {
|ArticleMeta {
title,
date,
- filename,
+ canonical_name,
..
}| {
let title = escape(title);
@@ -27,7 +27,7 @@ pub fn generate_atom(args: &Args) -> String {
r#"
<entry>
<title>{title}</title>
- <link href="https://{BLOG_BASE}/{filename}.html" />
+ <link href="https://{BLOG_BASE}/{canonical_name}.html" />
<id>tag:metamuffin.org,{date},{title}</id>
<published>{datetime}</published>
<summary>N/A</summary>
diff --git a/code/src/html.rs b/code/src/html.rs
index bdc9a78..64b4c6d 100644
--- a/code/src/html.rs
+++ b/code/src/html.rs
@@ -1,4 +1,4 @@
-use crate::{article_metadata, get_articles, markdown::blocks_to_html};
+use crate::{article_metadata, get_articles, markdown::blocks_to_html, ArticleMeta};
use laby::{html, iter, li, ul, Render};
use std::fs::read_to_string;
@@ -9,7 +9,12 @@ pub fn scaffold(title: String, body: impl Render) -> impl Render {
title!(format!("{} - metamuffin's blog", title))
),
body!(
- nav!(h2!("metamuffin's blog"), a!(href = "./index.html", "index")),
+ nav!(
+ h2!("metamuffin's blog"),
+ a!(href = "./index.html", "index"),
+ " ",
+ a!(href = "./feed.atom", "atom")
+ ),
article!(body),
footer!(p!("written by metamuffin, licensed under CC-BY-ND-4.0"))
)
@@ -29,16 +34,20 @@ pub fn index(root: &str) -> impl Render {
scaffold(
"index".to_string(),
ul!(iter!({
- get_articles(&root).into_iter().map(|meta| {
- li!(
- meta.date.to_string(),
- ": ",
- a!(
- href = format!("./{}", meta.path.to_str().unwrap().replace(".md", ".html")),
- meta.title
+ get_articles(&root).into_iter().map(
+ |ArticleMeta {
+ canonical_name,
+ date,
+ title,
+ ..
+ }| {
+ li!(
+ date.to_string(),
+ ": ",
+ a!(href = format!("./{canonical_name}.html",), title)
)
- )
- })
+ },
+ )
})),
)
}
diff --git a/code/src/main.rs b/code/src/main.rs
index 693c120..83bcefe 100644
--- a/code/src/main.rs
+++ b/code/src/main.rs
@@ -74,7 +74,7 @@ pub fn get_articles(root: &str) -> Vec<ArticleMeta> {
pub struct ArticleMeta {
title: String,
- filename: String,
+ canonical_name: String,
date: iso8601::Date,
path: PathBuf,
}
@@ -85,7 +85,7 @@ fn article_metadata(path: PathBuf) -> ArticleMeta {
f.read_line(&mut buf).unwrap(); // assume the 1st line has the title
ArticleMeta {
title: String::from(buf[2..].trim()),
- filename: path.file_name().unwrap().to_str().unwrap().to_string(),
+ canonical_name: path.file_stem().unwrap().to_str().unwrap().to_string(),
date: iso8601::date(&path.file_name().unwrap().to_str().unwrap()[0..10]).unwrap(),
path,
}