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

@ -1,4 +1,5 @@
{% import "partials/language.html" as lang with context %}
{% set feature = config.theme.feature %}
{% set palette = config.theme.palette %}
{% set font = config.theme.font %}
<!DOCTYPE html>
@ -104,7 +105,6 @@
{% include "partials/header.html" %}
{% endblock %}
<div class="md-container">
{% set feature = config.extra.get("feature", {}) %}
{% if feature.tabs %}
{% include "partials/tabs.html" %}
{% endif %}

View File

@ -16,6 +16,12 @@
# IN THE SOFTWARE.
# 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

@ -1,11 +1,4 @@
{% 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 "partials/language/" + (languages | first) + ".html" as lang %}
{% import "partials/language/" + config.theme.language + ".html" as lang %}
{% macro t(key) %}{{ {
"search.languages": languages | join(", ")
"search.languages": (config.extra.search | default({})).language | default("")
}[key] or lang.t(key) }}{% endmacro %}

View File

@ -37,22 +37,23 @@ theme:
custom_dir: material
# Same values as in mkdocs_theme.yml
language: kr
language: en
feature:
tabs: false
palette:
primary:
accent:
font:
text: Roboto
code: Roboto Mono
palette:
primary:
accent: blue
plugins:
- search: null
#plugins: []
# Options
extra:
language: en
feature:
tabs: false
search:
languages: en, de, fr
social:
- type: globe
link: http://struct.cc

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 %}