diff options
| author | Fuwn <[email protected]> | 2024-06-16 16:21:58 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-06-16 16:21:58 -0700 |
| commit | cb6c83ea22e36eb778a06f4bb92060166e11a94b (patch) | |
| tree | cd5c94fdc4e5fd92c85e51870f55f4a91f1438f1 /src | |
| parent | feat(response): variable header image (diff) | |
| download | locus-cb6c83ea22e36eb778a06f4bb92060166e11a94b.tar.xz locus-cb6c83ea22e36eb778a06f4bb92060166e11a94b.zip | |
fix(blog): use real title for xml title
Diffstat (limited to 'src')
| -rw-r--r-- | src/modules/blog/module.rs | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/src/modules/blog/module.rs b/src/modules/blog/module.rs index 6a36429..7c10b21 100644 --- a/src/modules/blog/module.rs +++ b/src/modules/blog/module.rs @@ -16,17 +16,18 @@ // Copyright (C) 2022-2022 Fuwn <[email protected]> // SPDX-License-Identifier: GPL-3.0-only -use std::{ - collections::HashMap, - fs::{self, read_dir}, - io::Read, -}; - -use crate::{ - modules::blog::config::Blog, - response::success, - route::track_mount, - xml::{Item as XmlItem, Writer as XmlWriter}, +use { + crate::{ + modules::blog::config::Blog, + response::success, + route::track_mount, + xml::{Item as XmlItem, Writer as XmlWriter}, + }, + std::{ + collections::HashMap, + fs::{self, read_dir}, + io::Read, + }, }; #[allow(clippy::too_many_lines)] @@ -39,15 +40,11 @@ pub fn module(router: &mut windmark::router::Router) { let blog_paths = read_dir(&blog).unwrap(); let mut entries: HashMap<_, String> = HashMap::new(); - blog_paths - .map(|e| e.unwrap().path().display().to_string()) - .for_each(|file| { + blog_paths.map(|e| e.unwrap().path().display().to_string()).for_each( + |file| { let mut contents = String::new(); - fs::File::open(&file) - .unwrap() - .read_to_string(&mut contents) - .unwrap(); + fs::File::open(&file).unwrap().read_to_string(&mut contents).unwrap(); entries.insert( file.replace(&blog, "").replace(".gmi", "").replace( @@ -66,7 +63,8 @@ pub fn module(router: &mut windmark::router::Router) { ), contents, ); - }); + }, + ); blogs.insert( blog @@ -90,9 +88,7 @@ pub fn module(router: &mut windmark::router::Router) { let mut c = s.chars(); c.next().map_or_else(String::new, |f| { - f.to_uppercase() - .chain(c.flat_map(char::to_lowercase)) - .collect() + f.to_uppercase().chain(c.flat_map(char::to_lowercase)).collect() }) }) .collect::<Vec<_>>() @@ -239,7 +235,6 @@ pub fn module(router: &mut windmark::router::Router) { xml.add_item(&{ let mut builder = XmlItem::builder(); - builder.add_field("title", &title); builder.add_field( "link", &format!( @@ -272,6 +267,8 @@ pub fn module(router: &mut windmark::router::Router) { } } + builder.add_field("title", real_title); + builder }); |