Ensure lang is always set on default sections

This commit is contained in:
Vincent Prouillet 2020-04-12 19:17:29 +02:00
parent fb6cbe008f
commit b2eb00a374
4 changed files with 4 additions and 2 deletions

View file

@ -458,13 +458,13 @@ impl Site {
let filename = format!("_index.{}.md", l);
index_section.file.path = self.content_path.join(&filename);
index_section.file.relative = filename;
index_section.lang = index_section.file.find_language(&self.config)?;
} else {
index_section.file.name = "_index".to_string();
index_section.permalink = self.config.make_permalink("");
index_section.file.path = self.content_path.join("_index.md");
index_section.file.relative = "_index.md".to_string();
}
index_section.lang = index_section.file.find_language(&self.config)?;
library.insert_section(index_section);
}
}

View file

@ -18,7 +18,7 @@ A few variables are available on all templates except RSS and the sitemap:
- `config`: the [configuration](@/documentation/getting-started/configuration.md) without any modifications
- `current_path`: the path (full URL without `base_url`) of the current page, never starting with a `/`
- `current_url`: the full URL for the current page
- `lang`: the language for the current page; `null` if the page/section doesn't have a language set
- `lang`: the language for the current page
Config variables can be accessed like `config.variable`, in HTML for example with `{{ config.base_url }}`.
The 404 template does not get `current_path` and `current_url` (this information cannot be determined).

View file

@ -1,3 +1,4 @@
{% for author in terms %}
{{ author.name }} {{ author.slug }} {{ author.pages | length }}
{% endfor %}
{{lang}}

View file

@ -19,3 +19,4 @@
{% if paginator.previous %}has_prev{% endif%}
{% if paginator.next %}has_next{% endif%}
{% endif %}
{{lang}}