comments
This commit is contained in:
parent
2bfd9170c5
commit
4eb1ae5402
1 changed files with 15 additions and 11 deletions
26
src/main.rs
26
src/main.rs
|
@ -194,10 +194,12 @@ async fn render(
|
|||
.finish());
|
||||
}
|
||||
|
||||
// If the path is not a markdown file (e.g. photos), just return it as it is.
|
||||
if full_path.exists() && !path.ends_with(".md") {
|
||||
return Ok(NamedFile::open(full_path)?.into_response(&request)?);
|
||||
}
|
||||
|
||||
// Otherwise, retrieve it and check backlinks
|
||||
let filename = full_path
|
||||
.components()
|
||||
.last()
|
||||
|
@ -208,17 +210,6 @@ async fn render(
|
|||
|
||||
let normalized_name = normalize_name(filename);
|
||||
|
||||
let mut recently_changed = cache
|
||||
.pages
|
||||
.clone()
|
||||
.into_iter()
|
||||
.filter_map(|i| match i.1.timestamp {
|
||||
Some(ts) => Some((i.0, SystemTime::now().duration_since(ts).unwrap())),
|
||||
None => None,
|
||||
})
|
||||
.collect::<Vec<(String, Duration)>>();
|
||||
recently_changed.sort_by_key(|i| i.1);
|
||||
|
||||
let mut backlinks: Vec<String> = vec![];
|
||||
for (path, page) in cache.pages.iter() {
|
||||
if page
|
||||
|
@ -232,8 +223,21 @@ async fn render(
|
|||
|
||||
let page = cache.pages.get(path.as_ref());
|
||||
|
||||
// Recently changed
|
||||
let mut recently_changed = cache
|
||||
.pages
|
||||
.clone()
|
||||
.into_iter()
|
||||
.filter_map(|i| match i.1.timestamp {
|
||||
Some(ts) => Some((i.0, SystemTime::now().duration_since(ts).unwrap())),
|
||||
None => None,
|
||||
})
|
||||
.collect::<Vec<(String, Duration)>>();
|
||||
recently_changed.sort_by_key(|i| i.1);
|
||||
|
||||
let timeago = timeago::Formatter::new();
|
||||
|
||||
// Render context generation
|
||||
let mut context = Context::new();
|
||||
context.insert("version", VERSION);
|
||||
context.insert(
|
||||
|
|
Loading…
Reference in a new issue