Fix post indexing
This commit is contained in:
@@ -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 = {
|
||||
{
|
||||
|
||||
@@ -20,7 +20,9 @@ struct Entry {
|
||||
#[allow(dead_code)]
|
||||
short_name: String,
|
||||
file_path: String,
|
||||
timestamp: DateTime<Utc>,
|
||||
created_timestamp: DateTime<Utc>,
|
||||
#[allow(dead_code)]
|
||||
modified_timestamp: DateTime<Utc>,
|
||||
status: i32,
|
||||
}
|
||||
|
||||
@@ -47,7 +49,9 @@ impl PostManager {
|
||||
|
||||
fn query_posts(&self) -> Result<HashMap<String, Entry>, 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<footer style="margin-top: 50px; padding-top: 20px; border-top: 1px solid #ddd; color: #666; text-align: center;">
|
||||
<p>My Static Blog - Powered by Rust and CommonMark</p>
|
||||
<p>Guus Waals - updated on $<updated/> ($<version/>)</p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user