parent
7fc7ef4720
commit
2a46e07e74
|
@ -15,6 +15,7 @@
|
||||||
- Image processing now supports WebP
|
- Image processing now supports WebP
|
||||||
- Fix `zola serve` failing for some static files
|
- Fix `zola serve` failing for some static files
|
||||||
- Fix `zola serve` not picking up directory renaming
|
- Fix `zola serve` not picking up directory renaming
|
||||||
|
- Add `path` to the taxonomy terms to be on par with pages and sections
|
||||||
|
|
||||||
## 0.13.0 (2021-01-09)
|
## 0.13.0 (2021-01-09)
|
||||||
|
|
||||||
|
|
|
@ -413,6 +413,7 @@ mod tests {
|
||||||
let taxonomy_item = TaxonomyItem {
|
let taxonomy_item = TaxonomyItem {
|
||||||
name: "Something".to_string(),
|
name: "Something".to_string(),
|
||||||
slug: "something".to_string(),
|
slug: "something".to_string(),
|
||||||
|
path: "/tags/something".to_string(),
|
||||||
permalink: "https://vincent.is/tags/something/".to_string(),
|
permalink: "https://vincent.is/tags/something/".to_string(),
|
||||||
pages: library.pages().keys().collect(),
|
pages: library.pages().keys().collect(),
|
||||||
};
|
};
|
||||||
|
@ -446,6 +447,7 @@ mod tests {
|
||||||
let taxonomy_item = TaxonomyItem {
|
let taxonomy_item = TaxonomyItem {
|
||||||
name: "Something".to_string(),
|
name: "Something".to_string(),
|
||||||
slug: "something".to_string(),
|
slug: "something".to_string(),
|
||||||
|
path: "/some-tags/something/".to_string(),
|
||||||
permalink: "https://vincent.is/some-tags/something/".to_string(),
|
permalink: "https://vincent.is/some-tags/something/".to_string(),
|
||||||
pages: library.pages().keys().collect(),
|
pages: library.pages().keys().collect(),
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,6 +18,7 @@ use utils::slugs::slugify_paths;
|
||||||
pub struct SerializedTaxonomyItem<'a> {
|
pub struct SerializedTaxonomyItem<'a> {
|
||||||
name: &'a str,
|
name: &'a str,
|
||||||
slug: &'a str,
|
slug: &'a str,
|
||||||
|
path: &'a str,
|
||||||
permalink: &'a str,
|
permalink: &'a str,
|
||||||
pages: Vec<SerializingPage<'a>>,
|
pages: Vec<SerializingPage<'a>>,
|
||||||
}
|
}
|
||||||
|
@ -34,6 +35,7 @@ impl<'a> SerializedTaxonomyItem<'a> {
|
||||||
SerializedTaxonomyItem {
|
SerializedTaxonomyItem {
|
||||||
name: &item.name,
|
name: &item.name,
|
||||||
slug: &item.slug,
|
slug: &item.slug,
|
||||||
|
path: &item.path,
|
||||||
permalink: &item.permalink,
|
permalink: &item.permalink,
|
||||||
pages,
|
pages,
|
||||||
}
|
}
|
||||||
|
@ -45,6 +47,7 @@ impl<'a> SerializedTaxonomyItem<'a> {
|
||||||
pub struct TaxonomyItem {
|
pub struct TaxonomyItem {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub slug: String,
|
pub slug: String,
|
||||||
|
pub path: String,
|
||||||
pub permalink: String,
|
pub permalink: String,
|
||||||
pub pages: Vec<DefaultKey>,
|
pub pages: Vec<DefaultKey>,
|
||||||
}
|
}
|
||||||
|
@ -73,16 +76,17 @@ impl TaxonomyItem {
|
||||||
.collect();
|
.collect();
|
||||||
let (mut pages, ignored_pages) = sort_pages_by_date(data);
|
let (mut pages, ignored_pages) = sort_pages_by_date(data);
|
||||||
let item_slug = slugify_paths(name, config.slugify.taxonomies);
|
let item_slug = slugify_paths(name, config.slugify.taxonomies);
|
||||||
let permalink = if taxonomy.lang != config.default_language {
|
let path = if taxonomy.lang != config.default_language {
|
||||||
config.make_permalink(&format!("/{}/{}/{}", taxonomy.lang, taxo_slug, item_slug))
|
format!("/{}/{}/{}/", taxonomy.lang, taxo_slug, item_slug)
|
||||||
} else {
|
} else {
|
||||||
config.make_permalink(&format!("/{}/{}", taxo_slug, item_slug))
|
format!("/{}/{}/", taxo_slug, item_slug)
|
||||||
};
|
};
|
||||||
|
let permalink = config.make_permalink(&path);
|
||||||
|
|
||||||
// We still append pages without dates at the end
|
// We still append pages without dates at the end
|
||||||
pages.extend(ignored_pages);
|
pages.extend(ignored_pages);
|
||||||
|
|
||||||
TaxonomyItem { name: name.to_string(), permalink, slug: item_slug, pages }
|
TaxonomyItem { name: name.to_string(), permalink, path, slug: item_slug, pages }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn serialize<'a>(&'a self, library: &'a Library) -> SerializedTaxonomyItem<'a> {
|
pub fn serialize<'a>(&'a self, library: &'a Library) -> SerializedTaxonomyItem<'a> {
|
||||||
|
@ -338,6 +342,7 @@ mod tests {
|
||||||
assert_eq!(tags.items[0].name, "db");
|
assert_eq!(tags.items[0].name, "db");
|
||||||
assert_eq!(tags.items[0].slug, "db");
|
assert_eq!(tags.items[0].slug, "db");
|
||||||
assert_eq!(tags.items[0].permalink, "http://a-website.com/tags/db/");
|
assert_eq!(tags.items[0].permalink, "http://a-website.com/tags/db/");
|
||||||
|
assert_eq!(tags.items[0].path, "/tags/db/");
|
||||||
assert_eq!(tags.items[0].pages.len(), 1);
|
assert_eq!(tags.items[0].pages.len(), 1);
|
||||||
|
|
||||||
assert_eq!(tags.items[1].name, "js");
|
assert_eq!(tags.items[1].name, "js");
|
||||||
|
@ -438,6 +443,7 @@ mod tests {
|
||||||
assert_eq!(tags.items[1].name, "js");
|
assert_eq!(tags.items[1].name, "js");
|
||||||
assert_eq!(tags.items[1].slug, "js");
|
assert_eq!(tags.items[1].slug, "js");
|
||||||
assert_eq!(tags.items[1].permalink, "http://a-website.com/tags/js/");
|
assert_eq!(tags.items[1].permalink, "http://a-website.com/tags/js/");
|
||||||
|
assert_eq!(tags.items[1].path, "/tags/js/");
|
||||||
assert_eq!(tags.items[1].pages.len(), 2);
|
assert_eq!(tags.items[1].pages.len(), 2);
|
||||||
|
|
||||||
assert_eq!(tags.items[2].name, "rust");
|
assert_eq!(tags.items[2].name, "rust");
|
||||||
|
|
|
@ -13,6 +13,7 @@ First, `TaxonomyTerm` has the following fields:
|
||||||
```ts
|
```ts
|
||||||
name: String;
|
name: String;
|
||||||
slug: String;
|
slug: String;
|
||||||
|
path: String;
|
||||||
permalink: String;
|
permalink: String;
|
||||||
pages: Array<Page>;
|
pages: Array<Page>;
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in a new issue