mirror of
https://github.com/getzola/zola
synced 2024-11-10 06:14:19 +00:00
Add path to TranslatedContent
(#863)
* Add path to `TranslatedContent` This makes it possible to retrieve the translated page through the `get_page` function. * Use TranslatedContent::path field in test_site_i18n Use it with the `get_page` function to get a reference to the page object.
This commit is contained in:
parent
73ea4b3b16
commit
72373bea9b
3 changed files with 15 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
//! What we are sending to the templates when rendering them
|
||||
use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
|
||||
use tera::{Map, Value};
|
||||
|
||||
|
@ -12,6 +13,9 @@ pub struct TranslatedContent<'a> {
|
|||
lang: &'a str,
|
||||
permalink: &'a str,
|
||||
title: &'a Option<String>,
|
||||
/// The path to the markdown file; useful for retrieving the full page through
|
||||
/// the `get_page` function.
|
||||
path: &'a Path,
|
||||
}
|
||||
|
||||
impl<'a> TranslatedContent<'a> {
|
||||
|
@ -25,6 +29,7 @@ impl<'a> TranslatedContent<'a> {
|
|||
lang: &other.lang,
|
||||
permalink: &other.permalink,
|
||||
title: &other.meta.title,
|
||||
path: &other.file.path,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -40,6 +45,7 @@ impl<'a> TranslatedContent<'a> {
|
|||
lang: &other.lang,
|
||||
permalink: &other.permalink,
|
||||
title: &other.meta.title,
|
||||
path: &other.file.path,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -132,5 +132,8 @@ lang: String?;
|
|||
title: String?;
|
||||
// A permalink to that content
|
||||
permalink: String;
|
||||
// The path to the markdown file; useful for retrieving the full page through
|
||||
// the `get_page` function.
|
||||
path: String;
|
||||
```
|
||||
|
||||
|
|
|
@ -4,6 +4,12 @@ Language: {{lang}}
|
|||
|
||||
{% for t in page.translations %}
|
||||
Translated in {{t.lang|default(value=config.default_language)}}: {{t.title}} {{t.permalink|safe}}
|
||||
|
||||
<br><br>
|
||||
|
||||
{% set translated_page = get_page(path = t.path) %}
|
||||
{{ translated_page.content | safe }}
|
||||
|
||||
{% endfor %}
|
||||
|
||||
{% for taxo_kind, items in page.taxonomies %}
|
||||
|
|
Loading…
Reference in a new issue