Make get_all_orphan_pages more idiomatic
This commit is contained in:
parent
2d7315676b
commit
34d17e613d
|
@ -149,20 +149,15 @@ impl Site {
|
|||
|
||||
/// Get all the orphan (== without section) pages in the site
|
||||
pub fn get_all_orphan_pages(&self) -> Vec<&Page> {
|
||||
let mut pages_in_sections = HashSet::new();
|
||||
let mut orphans = vec![];
|
||||
let pages_in_sections = self.sections
|
||||
.values()
|
||||
.flat_map(|s| s.all_pages_path())
|
||||
.collect::<HashSet<_>>();
|
||||
|
||||
for s in self.sections.values() {
|
||||
pages_in_sections.extend(s.all_pages_path());
|
||||
}
|
||||
|
||||
for page in self.pages.values() {
|
||||
if !pages_in_sections.contains(&page.file.path) {
|
||||
orphans.push(page);
|
||||
}
|
||||
}
|
||||
|
||||
orphans
|
||||
self.pages
|
||||
.values()
|
||||
.filter(|page| !pages_in_sections.contains(&page.file.path))
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn set_base_url(&mut self, base_url: String) {
|
||||
|
|
Loading…
Reference in a new issue