Moved language and features to theme configuration

This commit is contained in:
squidfunk
2017-10-31 18:51:54 +01:00
committed by Martin Donath
parent a5d90ea2a9
commit 5fbba74c80
7 changed files with 29 additions and 30 deletions

View File

@@ -23,6 +23,7 @@
{% import "partials/language.html" as lang with context %}
<!-- Theme options -->
{% set feature = config.theme.feature %}
{% set palette = config.theme.palette %}
{% set font = config.theme.font %}
@@ -200,7 +201,6 @@
<!-- Container, necessary for web-application context -->
<div class="md-container">
{% set feature = config.extra.get("feature", {}) %}
<!-- Tabs with outline -->
{% if feature.tabs %}

View File

@@ -21,6 +21,14 @@
# Language for theme localization
language: en
# Feature flags for functionality that alters behavior significantly, and thus
# may be a matter of taste
feature:
# Another layer on top of the main navigation for larger screens in the form
# of tabs, especially useful for larger documentation projects
tabs: false
# Sets the primary and accent color palettes as defined in the Material Design
# documentation - possible values can be looked up in the getting started guide
palette:

View File

@@ -20,19 +20,10 @@
IN THE SOFTWARE.
-->
<!-- Normalize language configuration -->
{% set languages = "en" %}
{% if config and config.theme %}
{% set languages = config.theme.language | default("en") %}
{% endif %}
{% if languages is string %}
{% set languages = languages.split(",") | map("trim") %}
{% endif %}
<!-- Import translations for given language -->
{% import "partials/language/" + (languages | first) + ".html" as lang %}
{% import "partials/language/" + config.theme.language + ".html" as lang %}
<!-- Re-export translations -->
{% macro t(key) %}{{ {
"search.languages": languages | join(", ")
"search.languages": (config.extra.search | default({})).language | default("")
}[key] or lang.t(key) }}{% endmacro %}