Skip to content

Commit

Permalink
Add option to have a prefix for a taxonomy
Browse files Browse the repository at this point in the history
As seen in #2449, it might be nice to not serve the taxonomies in the
top level directory, but in a subfolder. This commit adds an option
"prefix" to the taxonomy definition.

The taxonomy then would be served in /<prefix>/<taxonomy_name> instead of
/<taxonomy>.
  • Loading branch information
Mandragorian committed Nov 15, 2024
1 parent ab0ad33 commit f739c68
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions components/config/src/config/taxonomies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use serde::{Deserialize, Serialize};
pub struct TaxonomyConfig {
/// The name used in the URL, usually the plural
pub name: String,
/// The prefix used in the URL.
pub prefix: Option<String>,
/// The slug according to the config slugification strategy
pub slug: String,
/// If this is set, the list of individual taxonomy term page will be paginated
Expand All @@ -21,6 +23,7 @@ impl Default for TaxonomyConfig {
fn default() -> Self {
Self {
name: String::new(),
prefix: None,
slug: String::new(),
paginate_by: None,
paginate_path: None,
Expand Down
4 changes: 4 additions & 0 deletions components/site/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,10 @@ impl Site {
components.push(taxonomy.lang.as_ref());
}

if let Some(prefix) = &taxonomy.kind.prefix {
components.push(prefix.as_ref());
}

components.push(taxonomy.slug.as_ref());

let list_output =
Expand Down

0 comments on commit f739c68

Please sign in to comment.