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" })
|
{ nargs = '*', desc = "Update run/debug arguments" })
|
||||||
|
|
||||||
if dap_ok then
|
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 = {
|
local lldb_init = {
|
||||||
"command script import ~/.rustup/toolchains/nightly-2025-02-19-aarch64-apple-darwin/lib/rustlib/etc/lldb_lookup.py",
|
"command script import "..rust_path.."/lib/rustlib/etc/lldb_lookup.py",
|
||||||
"command source ~/.rustup/toolchains/nightly-2025-02-19-aarch64-apple-darwin/lib/rustlib/etc/lldb_commands",
|
"command source "..rust_path.."lib/rustlib/etc/lldb_commands",
|
||||||
}
|
}
|
||||||
dap_configs = {
|
dap_configs = {
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ struct Entry {
|
|||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
short_name: String,
|
short_name: String,
|
||||||
file_path: String,
|
file_path: String,
|
||||||
timestamp: DateTime<Utc>,
|
created_timestamp: DateTime<Utc>,
|
||||||
|
#[allow(dead_code)]
|
||||||
|
modified_timestamp: DateTime<Utc>,
|
||||||
status: i32,
|
status: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +49,9 @@ impl PostManager {
|
|||||||
|
|
||||||
fn query_posts(&self) -> Result<HashMap<String, Entry>, String> {
|
fn query_posts(&self) -> Result<HashMap<String, Entry>, String> {
|
||||||
let output = Command::new("git")
|
let output = Command::new("git")
|
||||||
.arg("whatchanged")
|
.arg("log")
|
||||||
|
.arg("--raw")
|
||||||
|
.arg("--no-merges")
|
||||||
.arg("--pretty=%h - %ad - %s")
|
.arg("--pretty=%h - %ad - %s")
|
||||||
.arg("--date=unix")
|
.arg("--date=unix")
|
||||||
.arg("--")
|
.arg("--")
|
||||||
@@ -99,16 +103,20 @@ impl PostManager {
|
|||||||
let status = parts[4]; // A (add), D (delete), M (modify)
|
let status = parts[4]; // A (add), D (delete), M (modify)
|
||||||
let file_path = parts[5];
|
let file_path = parts[5];
|
||||||
|
|
||||||
if let Some(file_name) = file_path.strip_prefix("posts/") {
|
let fn_ = file_path
|
||||||
if let Some(name) = file_name.strip_suffix(".md") {
|
.strip_prefix("posts/")
|
||||||
// Only update if we don't have a timestamp yet (latest commit wins)
|
.and_then(|s| s.strip_suffix(".md"));
|
||||||
result.entry(name.to_string()).or_insert(Entry {
|
if let Some(name) = fn_ {
|
||||||
|
let entry = result.entry(name.to_string()).or_insert(Entry {
|
||||||
short_name: name.to_string(),
|
short_name: name.to_string(),
|
||||||
file_path: file_path.to_string(),
|
file_path: file_path.to_string(),
|
||||||
timestamp,
|
created_timestamp: timestamp,
|
||||||
|
modified_timestamp: timestamp,
|
||||||
status: if status == "D" { -1 } else { 1 },
|
status: if status == "D" { -1 } else { 1 },
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
// Always use the oldest timestamp for posts creation dates
|
||||||
|
entry.created_timestamp = timestamp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -137,9 +145,9 @@ impl PostManager {
|
|||||||
filename: entry.file_path,
|
filename: entry.file_path,
|
||||||
markdown_content,
|
markdown_content,
|
||||||
html_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);
|
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;">
|
<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>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user