v0.2.1
This commit is contained in:
parent
c34ae002c2
commit
763f6ea969
6 changed files with 33 additions and 6 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -1441,7 +1441,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "mdws"
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "mdws"
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
edition = "2024"
|
||||
authors = ["Penelope Gwen <support@pogmom.me>"]
|
||||
license-file = "LICENSE.md"
|
||||
|
|
|
|||
7
debian/changelog
vendored
7
debian/changelog
vendored
|
|
@ -1,3 +1,10 @@
|
|||
mdws 0.2.1-1 semistable; urgency=medium
|
||||
|
||||
* enable listing page contents
|
||||
* better page content sorting
|
||||
|
||||
-- Penelope Gwen <support@pogmom.me> Tue, 06 Apr 2026 13:18:27 -0700
|
||||
|
||||
mdws 0.2.0-1 semistable; urgency=medium
|
||||
|
||||
* better date sorting
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use std::{cmp::Reverse, path::PathBuf};
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(serde::Deserialize, Debug, Clone)]
|
||||
pub struct FrontMatter {
|
||||
|
|
@ -75,7 +75,11 @@ pub fn get_markdown_modules(target_path: &PathBuf) -> Vec<MarkdownModule> {
|
|||
.reverse()
|
||||
}
|
||||
} else {
|
||||
e.metadata.index.partial_cmp(&f.metadata.index).unwrap()
|
||||
e.metadata
|
||||
.index
|
||||
.unwrap_or_default()
|
||||
.partial_cmp(&f.metadata.index.unwrap_or(999))
|
||||
.unwrap()
|
||||
}
|
||||
});
|
||||
mds
|
||||
|
|
|
|||
|
|
@ -102,14 +102,26 @@ pub fn sidebar_content(
|
|||
root_path: PathBuf,
|
||||
counter: i32,
|
||||
path: &str,
|
||||
page_path: &PathBuf,
|
||||
) -> Vec<MarkdownModule> {
|
||||
let sidebar_modules = markdowner::get_markdown_modules(target_path);
|
||||
let page_modules: Vec<String> = markdowner::get_markdown_modules(page_path)
|
||||
.iter()
|
||||
.filter(|m| m.path.file_stem().unwrap().ne("header"))
|
||||
.map(|m| {
|
||||
format!(
|
||||
"- [{}](#{})",
|
||||
m.metadata.title.clone(),
|
||||
m.path.file_stem().unwrap().to_str().unwrap(),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
let sidebar_modules: Vec<MarkdownModule> = sidebar_modules
|
||||
.iter()
|
||||
.map(|f| match f.metadata.title.as_str() {
|
||||
"rats" => random_image_module(f, "rats", root_path.clone()),
|
||||
"buttons" => random_image_module(f, "buttons", root_path.clone()),
|
||||
"sitemap" => sitemap(f, &root_path, counter, path),
|
||||
"sitemap" => sitemap(f, &root_path, counter, path, page_modules.clone()),
|
||||
_ => MarkdownModule {
|
||||
path: f.path.clone(),
|
||||
content: f.content.clone(),
|
||||
|
|
@ -125,6 +137,7 @@ fn sitemap(
|
|||
root_path: &PathBuf,
|
||||
counter: i32,
|
||||
path: &str,
|
||||
page_modules: Vec<String>,
|
||||
) -> MarkdownModule {
|
||||
let mut writer: Vec<u8> = Vec::new();
|
||||
let dir = PathItem(root_path.clone());
|
||||
|
|
@ -153,9 +166,12 @@ fn sitemap(
|
|||
|
||||
let tree_text = String::from_utf8(writer).expect("could not parse string from utf8");
|
||||
|
||||
let page_content = page_modules.join("\n\n");
|
||||
|
||||
let visit_count = format!("{}", counter);
|
||||
|
||||
values.insert("sitemap", tree_text.as_str());
|
||||
values.insert("content", page_content.as_str());
|
||||
values.insert("location", path);
|
||||
values.insert("visit_count", &visit_count.as_str());
|
||||
|
||||
|
|
@ -173,6 +189,5 @@ fn random_image(directory: &str, server_root: PathBuf) -> PathBuf {
|
|||
.map(|f| f.expect("umm what is this?").path())
|
||||
.choose(&mut rand::rng())
|
||||
.expect("where is my rat");
|
||||
//println!("{:#?}", rat_image);
|
||||
rat_image
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,6 +138,7 @@ fn renderer(
|
|||
config.server_root.clone(),
|
||||
counter,
|
||||
path.as_str(),
|
||||
&target_path,
|
||||
);
|
||||
|
||||
let response = if user_agent.starts_with("curl/") {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue