Skip to content

Commit

Permalink
Fix feed location for taxonomies not in the default language
Browse files Browse the repository at this point in the history
  • Loading branch information
Keats committed Jun 13, 2022
1 parent 4cb91da commit 4da81eb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 6 additions & 1 deletion components/site/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion components/site/tests/site_i18n.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
2 changes: 1 addition & 1 deletion test_site_i18n/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ taxonomies = [
[languages.fr]
generate_feed = true
taxonomies = [
{name = "auteurs"},
{name = "auteurs", feed = true},
{name = "tags"},
]

Expand Down

0 comments on commit 4da81eb

Please sign in to comment.