From 5fbba74c80dfe712edddf4c5c81bfec590774d44 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Tue, 31 Oct 2017 18:51:54 +0100 Subject: [PATCH] Moved language and features to theme configuration --- material/base.html | 2 +- material/mkdocs_theme.yml | 6 ++++++ material/partials/language.html | 11 ++--------- mkdocs.yml | 17 +++++++++-------- src/base.html | 2 +- src/mkdocs_theme.yml | 8 ++++++++ src/partials/language.html | 13 ++----------- 7 files changed, 29 insertions(+), 30 deletions(-) diff --git a/material/base.html b/material/base.html index 338b3ced9..be00d6829 100644 --- a/material/base.html +++ b/material/base.html @@ -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 %} @@ -104,7 +105,6 @@ {% include "partials/header.html" %} {% endblock %}
- {% set feature = config.extra.get("feature", {}) %} {% if feature.tabs %} {% include "partials/tabs.html" %} {% endif %} diff --git a/material/mkdocs_theme.yml b/material/mkdocs_theme.yml index d0d3ff226..8ddef23bb 100644 --- a/material/mkdocs_theme.yml +++ b/material/mkdocs_theme.yml @@ -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: diff --git a/material/partials/language.html b/material/partials/language.html index 523d10a1d..34b80c3db 100644 --- a/material/partials/language.html +++ b/material/partials/language.html @@ -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 %} diff --git a/mkdocs.yml b/mkdocs.yml index 037444a29..3aab83f22 100755 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -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 diff --git a/src/base.html b/src/base.html index 2d1b8f461..65cea6998 100644 --- a/src/base.html +++ b/src/base.html @@ -23,6 +23,7 @@ {% import "partials/language.html" as lang with context %} +{% set feature = config.theme.feature %} {% set palette = config.theme.palette %} {% set font = config.theme.font %} @@ -200,7 +201,6 @@
- {% set feature = config.extra.get("feature", {}) %} {% if feature.tabs %} diff --git a/src/mkdocs_theme.yml b/src/mkdocs_theme.yml index fa74252d4..1d99cc73e 100644 --- a/src/mkdocs_theme.yml +++ b/src/mkdocs_theme.yml @@ -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: diff --git a/src/partials/language.html b/src/partials/language.html index 4e0007b48..d44efb789 100644 --- a/src/partials/language.html +++ b/src/partials/language.html @@ -20,19 +20,10 @@ IN THE SOFTWARE. --> - -{% 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 %}