How to sort taxonomies, taking in account accentuated letters?

My blog is in French, and I’ve setup a tag cloud, but I got accentuated tag at the end of the list

écriture coming after zola for instance.

Is there a way to print the tag accentuated but in the correct sort order?

Hmm Zola doesn’t do any sorting on the tags so it might just be the serialization, maybe just tags | sort (maybe with | reverse if needed).

Si tu as du temps, https://github.com/getzola/zola/issues/768 a besoin d’avis niveau accents et autre :slight_smile:

I tried | sort but it stays at the end:

{% for ptag in terms | sort %}
  <span class="site-tag">
  {% set nb_pages = ptag.pages | length %}
  <a href="{{ ptag.permalink }}" style="font-size: {{ nb_pages * 4 + 80 }}%">{{ ptag.name }} ({{ ptag.pages | length }})</a>
</span>
    {% endfor %}

So we might have a bug?

(j’irais jeter un œil dès que possible :slight_smile: )

might be in Tera:

impl GetSortKey for String {
    fn get_sort_key(val: &Value) -> Result<Self> {
        let str: Result<&str> =
            val.as_str().ok_or_else(|| format!("expected string got {}", val).into());
        Ok(str?.to_owned())
    }
}

Maybe somekind of transformation needed here to make all accents their ASCII equivalent for sorting?

EDIT: I used https://lib.rs/crates/deunicode when implementing Jekyll’s filter slug in liquid-rust some time ago: https://github.com/cobalt-org/liquid-rust/commit/21a5be0b0f538ae67d31e5a23180f88af95df69d

If I want to tackle this, which package in zola I should point to my local version of Tera for experiments?

Probably easier to replace all of them, at least that’s what I do.

Ok thanks!

Another thing: on next branch, I noticed that components/rendering is not using the same version (beta.10) as the others (beta.17), is that intended?

Not a big deal, Cargo will use the same version since the beta versions are semver compatible

1 Like