From a5d90ea2a9ed7855151b2a144dfeb51b3f041516 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Tue, 31 Oct 2017 18:21:09 +0100 Subject: [PATCH] Moved font theme configuration --- material/base.html | 14 +++++----- material/mkdocs_theme.yml | 9 +++++++ material/partials/language.html | 4 +-- material/partials/language/kr.html | 18 +++++++++++++ mkdocs.yml | 7 ++--- src/base.html | 17 ++++++------- src/mkdocs_theme.yml | 13 ++++++++++ src/partials/language.html | 4 +-- src/partials/language/kr.html | 41 ++++++++++++++++++++++++++++++ 9 files changed, 104 insertions(+), 23 deletions(-) create mode 100644 material/partials/language/kr.html create mode 100644 src/partials/language/kr.html diff --git a/material/base.html b/material/base.html index 2ff114188..338b3ced9 100644 --- a/material/base.html +++ b/material/base.html @@ -1,5 +1,6 @@ {% import "partials/language.html" as lang with context %} {% set palette = config.theme.palette %} +{% set font = config.theme.font %} @@ -57,13 +58,12 @@ {% endif %} {% endblock %} {% block fonts %} - {% if config.extra.font != false and config.extra.font != "none" %} - {% set text = config.extra.get("font", {}).text | default("Roboto") %} - {% set code = config.extra.get("font", {}).code - | default("Roboto Mono") %} - {% set font = text + ":300,400,400i,700|" + code | replace(" ", "+") %} - - + {% if font != false %} + + {% endif %} {% endblock %} diff --git a/material/mkdocs_theme.yml b/material/mkdocs_theme.yml index 6e0358f80..d0d3ff226 100644 --- a/material/mkdocs_theme.yml +++ b/material/mkdocs_theme.yml @@ -14,6 +14,8 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. +# Language for theme localization +language: en # 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: @@ -21,6 +23,13 @@ palette: primary: # Accent color for highlighting user interaction, default: indigo accent: +# Fonts used by Material, automatically loaded from Google Fonts - see the site +# for a list of available fonts +font: + # Default font for text + text: Roboto + # Fixed-width font for code listings + code: Roboto Mono # Material includes the search in the header as a partial, not as a separate # template, so it's correct that search.html is missing include_search_page: false diff --git a/material/partials/language.html b/material/partials/language.html index a7de8a291..523d10a1d 100644 --- a/material/partials/language.html +++ b/material/partials/language.html @@ -1,6 +1,6 @@ {% set languages = "en" %} -{% if config and config.extra %} - {% set languages = config.extra.language | default("en") %} +{% if config and config.theme %} + {% set languages = config.theme.language | default("en") %} {% endif %} {% if languages is string %} {% set languages = languages.split(",") | map("trim") %} diff --git a/material/partials/language/kr.html b/material/partials/language/kr.html new file mode 100644 index 000000000..27163eb0b --- /dev/null +++ b/material/partials/language/kr.html @@ -0,0 +1,18 @@ +{% macro t(key) %}{{ { + "language": "kr", + "clipboard.copy": "클립보드로 복사", + "clipboard.copied": "클립보드에 복사됨", + "edit.link.title": "이 페이지를 편집", + "footer.previous": "이전", + "footer.next": "다음", + "meta.comments": "댓글", + "meta.source": "출처", + "search.placeholder": "검색", + "search.result.placeholder": "검색어를 입력하세요", + "search.result.none": "검색어와 일치하는 문서가 없습니다", + "search.result.one": "1개의 일치하는 문서", + "search.result.other": "#개의 일치하는 문서", + "search.tokenizer": "[\s\-]+", + "source.link.title": "저장소로 이동", + "toc.title": "목차" +}[key] }}{% endmacro %} diff --git a/mkdocs.yml b/mkdocs.yml index db061b2f2..037444a29 100755 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -37,6 +37,10 @@ theme: custom_dir: material # Same values as in mkdocs_theme.yml + language: kr + font: + text: Roboto + code: Roboto Mono palette: primary: accent: blue @@ -49,9 +53,6 @@ extra: language: en feature: tabs: false - palette: - primary: indigo - accent: indigo social: - type: globe link: http://struct.cc diff --git a/src/base.html b/src/base.html index 0301cadc1..2d1b8f461 100644 --- a/src/base.html +++ b/src/base.html @@ -24,6 +24,7 @@ {% set palette = config.theme.palette %} +{% set font = config.theme.font %} @@ -116,21 +117,19 @@ {% block fonts %} - - {% if config.extra.font != false and config.extra.font != "none" %} - {% set text = config.extra.get("font", {}).text | default("Roboto") %} - {% set code = config.extra.get("font", {}).code - | default("Roboto Mono") %} - {% set font = text + ":300,400,400i,700|" + code | replace(" ", "+") %} + {% if font != false %} + href="https://fonts.googleapis.com/css?family={{ + font.text | replace(' ', '+') + ':300,400,400i,700|' + + font.code | replace(' ', '+') + }}" /> diff --git a/src/mkdocs_theme.yml b/src/mkdocs_theme.yml index 099ddd2b7..fa74252d4 100644 --- a/src/mkdocs_theme.yml +++ b/src/mkdocs_theme.yml @@ -18,6 +18,9 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. +# Language for theme localization +language: en + # 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: @@ -28,6 +31,16 @@ palette: # Accent color for highlighting user interaction, default: indigo accent: +# Fonts used by Material, automatically loaded from Google Fonts - see the site +# for a list of available fonts +font: + + # Default font for text + text: Roboto + + # Fixed-width font for code listings + code: Roboto Mono + # Material includes the search in the header as a partial, not as a separate # template, so it's correct that search.html is missing include_search_page: false diff --git a/src/partials/language.html b/src/partials/language.html index 36deee12f..4e0007b48 100644 --- a/src/partials/language.html +++ b/src/partials/language.html @@ -22,8 +22,8 @@ {% set languages = "en" %} -{% if config and config.extra %} - {% set languages = config.extra.language | default("en") %} +{% if config and config.theme %} + {% set languages = config.theme.language | default("en") %} {% endif %} {% if languages is string %} {% set languages = languages.split(",") | map("trim") %} diff --git a/src/partials/language/kr.html b/src/partials/language/kr.html new file mode 100644 index 000000000..b449cd5fe --- /dev/null +++ b/src/partials/language/kr.html @@ -0,0 +1,41 @@ + + + +{% macro t(key) %}{{ { + "language": "kr", + "clipboard.copy": "클립보드로 복사", + "clipboard.copied": "클립보드에 복사됨", + "edit.link.title": "이 페이지를 편집", + "footer.previous": "이전", + "footer.next": "다음", + "meta.comments": "댓글", + "meta.source": "출처", + "search.placeholder": "검색", + "search.result.placeholder": "검색어를 입력하세요", + "search.result.none": "검색어와 일치하는 문서가 없습니다", + "search.result.one": "1개의 일치하는 문서", + "search.result.other": "#개의 일치하는 문서", + "search.tokenizer": "[\s\-]+", + "source.link.title": "저장소로 이동", + "toc.title": "목차" +}[key] }}{% endmacro %}