mirror of
https://github.com/getzola/zola
synced 2024-12-05 01:49:12 +00:00
fix: taxonomies missing lang in sitemap (#2373)
This commit is contained in:
parent
f560b48f43
commit
8ba73749b6
3 changed files with 14 additions and 15 deletions
|
@ -107,12 +107,8 @@ impl<'a> Paginator<'a> {
|
|||
paginate_reversed: false,
|
||||
root: PaginationRoot::Taxonomy(taxonomy, item),
|
||||
permalink: item.permalink.clone(),
|
||||
path: format!("/{}/{}/", taxonomy.slug, item.slug),
|
||||
paginate_path: taxonomy
|
||||
.kind
|
||||
.paginate_path
|
||||
.clone()
|
||||
.unwrap_or_else(|| "page".to_string()),
|
||||
path: item.path.clone(),
|
||||
paginate_path: taxonomy.kind.paginate_path().to_owned(),
|
||||
is_index: false,
|
||||
template: template.to_string(),
|
||||
};
|
||||
|
|
|
@ -92,14 +92,10 @@ pub fn find_entries<'a>(
|
|||
if !taxonomy.kind.render {
|
||||
continue;
|
||||
}
|
||||
let name = &taxonomy.kind.name;
|
||||
entries.insert(SitemapEntry::new(Cow::Owned(config.make_permalink(name)), &None));
|
||||
entries.insert(SitemapEntry::new(Cow::Borrowed(&taxonomy.permalink), &None));
|
||||
|
||||
for item in &taxonomy.items {
|
||||
entries.insert(SitemapEntry::new(
|
||||
Cow::Owned(config.make_permalink(&format!("{}/{}", name, item.slug))),
|
||||
&None,
|
||||
));
|
||||
entries.insert(SitemapEntry::new(Cow::Borrowed(&item.permalink), &None));
|
||||
|
||||
if taxonomy.kind.is_paginated() {
|
||||
let number_pagers = (item.pages.len() as f64
|
||||
|
@ -107,9 +103,8 @@ pub fn find_entries<'a>(
|
|||
.ceil() as isize;
|
||||
for i in 1..=number_pagers {
|
||||
let permalink = config.make_permalink(&format!(
|
||||
"{}/{}/{}/{}",
|
||||
name,
|
||||
item.slug,
|
||||
"{}{}/{}/",
|
||||
item.path,
|
||||
taxonomy.kind.paginate_path(),
|
||||
i
|
||||
));
|
||||
|
|
|
@ -169,6 +169,14 @@ fn can_build_multilingual_site() {
|
|||
assert!(file_contains!(public, "fr/tags/index.html", "bonjour"));
|
||||
assert!(!file_contains!(public, "fr/tags/index.html", "hello"));
|
||||
|
||||
// sitemap contains per-language taxonomies
|
||||
assert!(file_contains!(public, "sitemap.xml", "https://example.com/tags/"));
|
||||
assert!(file_contains!(public, "sitemap.xml", "https://example.com/tags/hello/"));
|
||||
assert!(file_contains!(public, "sitemap.xml", "https://example.com/fr/tags/"));
|
||||
assert!(file_contains!(public, "sitemap.xml", "https://example.com/fr/tags/bonjour/"));
|
||||
|
||||
assert!(!file_contains!(public, "sitemap.xml", "https://example.com/tags/bonjour"));
|
||||
|
||||
// one lang index per language
|
||||
assert!(file_exists!(public, "search_index.en.js"));
|
||||
assert!(file_exists!(public, "search_index.it.js"));
|
||||
|
|
Loading…
Reference in a new issue