Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to have a prefix for a taxonomy #2706

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 1 addition & 0 deletions components/site/tests/site.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ fn can_build_site_with_pagination_for_taxonomy() {
let (_, _tmp_dir, public) = build_site_with_setup("test_site", |mut site| {
site.config.languages.get_mut("en").unwrap().taxonomies.push(TaxonomyConfig {
name: "tags".to_string(),
prefix: None,
slug: "tags".to_string(),
paginate_by: Some(2),
paginate_path: None,
Expand Down