Merge pull request #662 from kgadek/sitemap-order
Sort sitemap elements by permalink
This commit is contained in:
commit
e12d0f8f3c
|
@ -777,11 +777,15 @@ impl Site {
|
||||||
ensure_directory_exists(&self.output_path)?;
|
ensure_directory_exists(&self.output_path)?;
|
||||||
|
|
||||||
let library = self.library.read().unwrap();
|
let library = self.library.read().unwrap();
|
||||||
let all_sitemap_entries = sitemap::find_entries(
|
let all_sitemap_entries = {
|
||||||
&library,
|
let mut all_sitemap_entries = sitemap::find_entries(
|
||||||
&self.taxonomies[..],
|
&library,
|
||||||
&self.config,
|
&self.taxonomies[..],
|
||||||
);
|
&self.config,
|
||||||
|
);
|
||||||
|
all_sitemap_entries.sort();
|
||||||
|
all_sitemap_entries
|
||||||
|
};
|
||||||
let sitemap_limit = 30000;
|
let sitemap_limit = 30000;
|
||||||
|
|
||||||
if all_sitemap_entries.len() < sitemap_limit {
|
if all_sitemap_entries.len() < sitemap_limit {
|
||||||
|
|
|
@ -5,6 +5,7 @@ use std::collections::{HashSet};
|
||||||
use tera::{Map, Value};
|
use tera::{Map, Value};
|
||||||
use config::{Config};
|
use config::{Config};
|
||||||
use library::{Library, Taxonomy};
|
use library::{Library, Taxonomy};
|
||||||
|
use std::cmp::Ordering;
|
||||||
|
|
||||||
/// The sitemap only needs links, potentially date and extra for pages in case of updates
|
/// The sitemap only needs links, potentially date and extra for pages in case of updates
|
||||||
/// for examples so we trim down all entries to only that
|
/// for examples so we trim down all entries to only that
|
||||||
|
@ -39,6 +40,18 @@ impl<'a> SitemapEntry<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> PartialOrd for SitemapEntry<'a> {
|
||||||
|
fn partial_cmp(&self, other: &SitemapEntry) -> Option<Ordering> {
|
||||||
|
Some(self.permalink.as_ref().cmp(other.permalink.as_ref()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Ord for SitemapEntry<'a> {
|
||||||
|
fn cmp(&self, other: &SitemapEntry) -> Ordering {
|
||||||
|
self.permalink.as_ref().cmp(other.permalink.as_ref())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Finds out all the links to put in a sitemap from the pages/sections/taxonomies
|
/// Finds out all the links to put in a sitemap from the pages/sections/taxonomies
|
||||||
/// There are no duplicate permalinks in the output vec
|
/// There are no duplicate permalinks in the output vec
|
||||||
pub fn find_entries<'a>(library: &'a Library, taxonomies: &'a [Taxonomy], config: &'a Config) -> Vec<SitemapEntry<'a>> {
|
pub fn find_entries<'a>(library: &'a Library, taxonomies: &'a [Taxonomy], config: &'a Config) -> Vec<SitemapEntry<'a>> {
|
||||||
|
|
Loading…
Reference in a new issue