From a5d90ea2a9ed7855151b2a144dfeb51b3f041516 Mon Sep 17 00:00:00 2001 From: squidfunk <martin.donath@squidfunk.com> 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 2ff11418..338b3ced 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 %} <!DOCTYPE html> <html lang="{{ lang.t('language') }}" class="no-js"> <head> @@ -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(" ", "+") %} - <link rel="stylesheet" href="https://fonts.googleapis.com/css?family={{ font }}"> - <style>body,input{font-family:"{{ text }}","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"{{ code }}","Courier New",Courier,monospace}</style> + {% if font != false %} + <link rel="stylesheet" href="https://fonts.googleapis.com/css?family={{ + font.text | replace(' ', '+') + ':300,400,400i,700|' + + font.code | replace(' ', '+') + }}"> + <style>body,input{font-family:"{{ font.text }}","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"{{ font.code }}","Courier New",Courier,monospace}</style> {% endif %} <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> {% endblock %} diff --git a/material/mkdocs_theme.yml b/material/mkdocs_theme.yml index 6e0358f8..d0d3ff22 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 a7de8a29..523d10a1 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 00000000..27163eb0 --- /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 db061b2f..037444a2 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 0301cadc..2d1b8f46 100644 --- a/src/base.html +++ b/src/base.html @@ -24,6 +24,7 @@ <!-- Theme options --> {% set palette = config.theme.palette %} +{% set font = config.theme.font %} <!DOCTYPE html> <html lang="{{ lang.t('language') }}" class="no-js"> @@ -116,21 +117,19 @@ <!-- Webfonts --> {% block fonts %} - <!-- TODO: remove the second check in the next major version --> - {% 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 %} <link rel="stylesheet" type="text/css" - href="https://fonts.googleapis.com/css?family={{ font }}" /> + href="https://fonts.googleapis.com/css?family={{ + font.text | replace(' ', '+') + ':300,400,400i,700|' + + font.code | replace(' ', '+') + }}" /> <style> body, input { - font-family: "{{ text }}", "Helvetica Neue", + font-family: "{{ font.text }}", "Helvetica Neue", Helvetica, Arial, sans-serif; } pre, code, kbd { - font-family: "{{ code }}", "Courier New", + font-family: "{{ font.code }}", "Courier New", Courier, monospace; } </style> diff --git a/src/mkdocs_theme.yml b/src/mkdocs_theme.yml index 099ddd2b..fa74252d 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 36deee12..4e0007b4 100644 --- a/src/partials/language.html +++ b/src/partials/language.html @@ -22,8 +22,8 @@ <!-- Normalize language configuration --> {% 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 00000000..b449cd5f --- /dev/null +++ b/src/partials/language/kr.html @@ -0,0 +1,41 @@ +<!-- + Copyright (c) 2016-2017 Martin Donath <martin.donath@squidfunk.com> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + 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. +--> + +<!-- Translations: Korean --> +{% 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 %} -- GitLab