From c0ac63b73c9cff6d688a6bc9788debff4cdf8de0 Mon Sep 17 00:00:00 2001 From: guus <_@guusw.nl> Date: Sat, 25 Oct 2025 14:05:21 +0800 Subject: [PATCH] Fix post indexing --- project_templates/.nvim.lua | 8 ++++++-- src/post_manager.rs | 36 ++++++++++++++++++++++-------------- templates/footer.html | 2 +- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/project_templates/.nvim.lua b/project_templates/.nvim.lua index 77e0fb9..2685f92 100644 --- a/project_templates/.nvim.lua +++ b/project_templates/.nvim.lua @@ -117,9 +117,13 @@ vim.api.nvim_create_user_command("Args", function(a) updateArgs(a.fargs) end, { nargs = '*', desc = "Update run/debug arguments" }) if dap_ok then + -- We need to query this to get the sysroot + -- ls $(rustc --print sysroot)/lib/rustlib/etc + local rust_path = vim.fn.system("rustc --print sysroot") + -- vim.print(rust_path) local lldb_init = { - "command script import ~/.rustup/toolchains/nightly-2025-02-19-aarch64-apple-darwin/lib/rustlib/etc/lldb_lookup.py", - "command source ~/.rustup/toolchains/nightly-2025-02-19-aarch64-apple-darwin/lib/rustlib/etc/lldb_commands", + "command script import "..rust_path.."/lib/rustlib/etc/lldb_lookup.py", + "command source "..rust_path.."lib/rustlib/etc/lldb_commands", } dap_configs = { { diff --git a/src/post_manager.rs b/src/post_manager.rs index 19dea81..c6c221e 100644 --- a/src/post_manager.rs +++ b/src/post_manager.rs @@ -20,7 +20,9 @@ struct Entry { #[allow(dead_code)] short_name: String, file_path: String, - timestamp: DateTime, + created_timestamp: DateTime, + #[allow(dead_code)] + modified_timestamp: DateTime, status: i32, } @@ -47,7 +49,9 @@ impl PostManager { fn query_posts(&self) -> Result, String> { let output = Command::new("git") - .arg("whatchanged") + .arg("log") + .arg("--raw") + .arg("--no-merges") .arg("--pretty=%h - %ad - %s") .arg("--date=unix") .arg("--") @@ -99,16 +103,20 @@ impl PostManager { let status = parts[4]; // A (add), D (delete), M (modify) let file_path = parts[5]; - if let Some(file_name) = file_path.strip_prefix("posts/") { - if let Some(name) = file_name.strip_suffix(".md") { - // Only update if we don't have a timestamp yet (latest commit wins) - result.entry(name.to_string()).or_insert(Entry { - short_name: name.to_string(), - file_path: file_path.to_string(), - timestamp, - status: if status == "D" { -1 } else { 1 }, - }); - } + let fn_ = file_path + .strip_prefix("posts/") + .and_then(|s| s.strip_suffix(".md")); + if let Some(name) = fn_ { + let entry = result.entry(name.to_string()).or_insert(Entry { + short_name: name.to_string(), + file_path: file_path.to_string(), + created_timestamp: timestamp, + modified_timestamp: timestamp, + status: if status == "D" { -1 } else { 1 }, + }); + + // Always use the oldest timestamp for posts creation dates + entry.created_timestamp = timestamp; } } } else { @@ -137,9 +145,9 @@ impl PostManager { filename: entry.file_path, markdown_content, html_content, - created_at: entry.timestamp, + created_at: entry.created_timestamp, }; - eprintln!("Loaded post: {} ({})", name, entry.timestamp); + eprintln!("Loaded post: {} ({})", name, entry.created_timestamp); self.posts.insert(name, post); } diff --git a/templates/footer.html b/templates/footer.html index 09baa70..23d9902 100644 --- a/templates/footer.html +++ b/templates/footer.html @@ -1,5 +1,5 @@