Moved font theme configuration

This commit is contained in:
squidfunk 2017-10-31 18:21:09 +01:00 committed by Martin Donath
parent 3afe613e63
commit a5d90ea2a9
9 changed files with 104 additions and 23 deletions

View File

@ -1,5 +1,6 @@
{% import "partials/language.html" as lang with context %} {% import "partials/language.html" as lang with context %}
{% set palette = config.theme.palette %} {% set palette = config.theme.palette %}
{% set font = config.theme.font %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="{{ lang.t('language') }}" class="no-js"> <html lang="{{ lang.t('language') }}" class="no-js">
<head> <head>
@ -57,13 +58,12 @@
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block fonts %} {% block fonts %}
{% if config.extra.font != false and config.extra.font != "none" %} {% if font != false %}
{% set text = config.extra.get("font", {}).text | default("Roboto") %} <link rel="stylesheet" href="https://fonts.googleapis.com/css?family={{
{% set code = config.extra.get("font", {}).code font.text | replace(' ', '+') + ':300,400,400i,700|' +
| default("Roboto Mono") %} font.code | replace(' ', '+')
{% 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:"{{ font.text }}","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"{{ font.code }}","Courier New",Courier,monospace}</style>
<style>body,input{font-family:"{{ text }}","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"{{ code }}","Courier New",Courier,monospace}</style>
{% endif %} {% endif %}
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
{% endblock %} {% endblock %}

View File

@ -14,6 +14,8 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # 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 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE. # IN THE SOFTWARE.
# Language for theme localization
language: en
# Sets the primary and accent color palettes as defined in the Material Design # 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 # documentation - possible values can be looked up in the getting started guide
palette: palette:
@ -21,6 +23,13 @@ palette:
primary: primary:
# Accent color for highlighting user interaction, default: indigo # Accent color for highlighting user interaction, default: indigo
accent: 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 # Material includes the search in the header as a partial, not as a separate
# template, so it's correct that search.html is missing # template, so it's correct that search.html is missing
include_search_page: false include_search_page: false

View File

@ -1,6 +1,6 @@
{% set languages = "en" %} {% set languages = "en" %}
{% if config and config.extra %} {% if config and config.theme %}
{% set languages = config.extra.language | default("en") %} {% set languages = config.theme.language | default("en") %}
{% endif %} {% endif %}
{% if languages is string %} {% if languages is string %}
{% set languages = languages.split(",") | map("trim") %} {% set languages = languages.split(",") | map("trim") %}

View File

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

View File

@ -37,6 +37,10 @@ theme:
custom_dir: material custom_dir: material
# Same values as in mkdocs_theme.yml # Same values as in mkdocs_theme.yml
language: kr
font:
text: Roboto
code: Roboto Mono
palette: palette:
primary: primary:
accent: blue accent: blue
@ -49,9 +53,6 @@ extra:
language: en language: en
feature: feature:
tabs: false tabs: false
palette:
primary: indigo
accent: indigo
social: social:
- type: globe - type: globe
link: http://struct.cc link: http://struct.cc

View File

@ -24,6 +24,7 @@
<!-- Theme options --> <!-- Theme options -->
{% set palette = config.theme.palette %} {% set palette = config.theme.palette %}
{% set font = config.theme.font %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="{{ lang.t('language') }}" class="no-js"> <html lang="{{ lang.t('language') }}" class="no-js">
@ -116,21 +117,19 @@
<!-- Webfonts --> <!-- Webfonts -->
{% block fonts %} {% block fonts %}
<!-- TODO: remove the second check in the next major version --> {% if font != false %}
{% 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" type="text/css" <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> <style>
body, input { body, input {
font-family: "{{ text }}", "Helvetica Neue", font-family: "{{ font.text }}", "Helvetica Neue",
Helvetica, Arial, sans-serif; Helvetica, Arial, sans-serif;
} }
pre, code, kbd { pre, code, kbd {
font-family: "{{ code }}", "Courier New", font-family: "{{ font.code }}", "Courier New",
Courier, monospace; Courier, monospace;
} }
</style> </style>

View File

@ -18,6 +18,9 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE. # IN THE SOFTWARE.
# Language for theme localization
language: en
# Sets the primary and accent color palettes as defined in the Material Design # 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 # documentation - possible values can be looked up in the getting started guide
palette: palette:
@ -28,6 +31,16 @@ palette:
# Accent color for highlighting user interaction, default: indigo # Accent color for highlighting user interaction, default: indigo
accent: 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 # Material includes the search in the header as a partial, not as a separate
# template, so it's correct that search.html is missing # template, so it's correct that search.html is missing
include_search_page: false include_search_page: false

View File

@ -22,8 +22,8 @@
<!-- Normalize language configuration --> <!-- Normalize language configuration -->
{% set languages = "en" %} {% set languages = "en" %}
{% if config and config.extra %} {% if config and config.theme %}
{% set languages = config.extra.language | default("en") %} {% set languages = config.theme.language | default("en") %}
{% endif %} {% endif %}
{% if languages is string %} {% if languages is string %}
{% set languages = languages.split(",") | map("trim") %} {% set languages = languages.split(",") | map("trim") %}

View File

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