Fix feed location for taxonomies not in the default language

This commit is contained in:
Vincent Prouillet 2022-06-13 22:34:47 +02:00
parent 4cb91dab0b
commit 4da81eb17e
4 changed files with 15 additions and 4 deletions

View File

@ -26,7 +26,8 @@ any pages related to that taxonomy
- Add a warning mode for internal/external link checking in case you don't want zola to stop the build on invalid links
- Always follow symlinks
- Add `rel="alternate"` to Atom post links
- Fix taxonomy current_path
- Fix taxonomy `current_path`
- Fix feed location for taxonomies not in the default language
## 0.15.3 (2022-01-23)

View File

@ -923,9 +923,14 @@ impl Site {
}
if taxonomy.kind.feed {
let tax_path = if taxonomy.lang == self.config.default_language {
PathBuf::from(format!("{}/{}", taxonomy.slug, item.slug))
} else {
PathBuf::from(format!("{}/{}/{}", taxonomy.lang, taxonomy.slug, item.slug))
};
self.render_feed(
item.pages.iter().map(|p| library.pages.get(p).unwrap()).collect(),
Some(&PathBuf::from(format!("{}/{}", taxonomy.slug, item.slug))),
Some(&tax_path),
&taxonomy.lang,
|mut context: Context| {
context.insert("taxonomy", &taxonomy.kind);

View File

@ -158,7 +158,12 @@ fn can_build_multilingual_site() {
assert!(file_exists!(public, "fr/auteurs/index.html"));
assert!(!file_contains!(public, "fr/auteurs/index.html", "Queen"));
assert!(file_contains!(public, "fr/auteurs/index.html", "Vincent"));
assert!(!file_exists!(public, "fr/auteurs/vincent-prouillet/atom.xml"));
assert!(file_exists!(public, "fr/auteurs/vincent-prouillet/atom.xml"));
assert!(file_contains!(
public,
"fr/auteurs/vincent-prouillet/atom.xml",
r#"<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fr">"#
));
assert!(file_exists!(public, "fr/tags/index.html"));
assert!(file_contains!(public, "fr/tags/index.html", "bonjour"));

View File

@ -19,7 +19,7 @@ taxonomies = [
[languages.fr]
generate_feed = true
taxonomies = [
{name = "auteurs"},
{name = "auteurs", feed = true},
{name = "tags"},
]