Moved palette to theme configuration

This commit is contained in:
squidfunk 2017-10-31 17:03:42 +01:00 committed by Martin Donath
parent 5ed16a0ae5
commit 3afe613e63
8 changed files with 76 additions and 19 deletions

View File

@ -56,9 +56,9 @@ export default (gulp, config, args) => {
autoprefixer(), autoprefixer(),
mqpacker mqpacker
].concat(!args.optimize ? [ ].concat(!args.optimize ? [
pseudoclasses({ // pseudoclasses({
"restrictTo": ["hover", "focus"] // "restrictTo": ["hover", "focus"]
}) // })
] : []))) ] : [])))
/* Minify sources */ /* Minify sources */

View File

@ -39,7 +39,9 @@ export default () => {
server.kill() server.kill()
/* Spawn MkDocs server */ /* Spawn MkDocs server */
server = child.spawn("mkdocs", ["serve", "--dev-addr", "0.0.0.0:8000"], { server = child.spawn("mkdocs", [
"serve", "--dev-addr", "0.0.0.0:8000", "--strict"
], {
stdio: "inherit" stdio: "inherit"
}) })
} }

View File

@ -1,4 +1,5 @@
{% import "partials/language.html" as lang with context %} {% import "partials/language.html" as lang with context %}
{% set palette = config.theme.palette %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="{{ lang.t('language') }}" class="no-js"> <html lang="{{ lang.t('language') }}" class="no-js">
<head> <head>
@ -51,7 +52,7 @@
{% endblock %} {% endblock %}
{% block styles %} {% block styles %}
<link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-04ea671600.css"> <link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-04ea671600.css">
{% if config.extra.palette %} {% if palette.primary or palette.accent %}
<link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-23f75ab9c7.palette.css"> <link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-23f75ab9c7.palette.css">
{% endif %} {% endif %}
{% endblock %} {% endblock %}
@ -71,11 +72,16 @@
{% endfor %} {% endfor %}
{% block extrahead %}{% endblock %} {% block extrahead %}{% endblock %}
</head> </head>
{% set palette = config.extra.get("palette", {}) %} {% if palette.primary or palette.accent %}
{% set primary = palette.primary | replace(" ", "-") | lower %} {% set primary = palette.primary | replace(" ", "-") | lower %}
{% set accent = palette.accent | replace(" ", "-") | lower %} {% set accent = palette.accent | replace(" ", "-") | lower %}
{% if primary or accent %} {% if palette.primary and palette.accent %}
<body data-md-color-primary="{{ primary }}" data-md-color-accent="{{ accent }}"> <body data-md-color-primary="{{ primary }}" data-md-color-accent="{{ accent }}">
{% elif palette.primary %}
<body data-md-color-primary="{{ primary }}">
{% elif palette.accent %}
<body data-md-color-accent="{{ accent }}">
{% endif %}
{% else %} {% else %}
<body> <body>
{% endif %} {% endif %}

View File

@ -14,6 +14,19 @@
# 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.
# 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:
# Primary color used for header, sidebar and links, default: indigo
primary:
# Accent color for highlighting user interaction, default: indigo
accent:
# 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
# Material doesn't use MkDocs search functionality but provides its own. For
# this reason, only the search index needs to be built
search_index_only: true
# Static pages to build # Static pages to build
static_templates: static_templates:
- 404.html - 404.html

View File

@ -32,7 +32,17 @@ repo_url: https://github.com/squidfunk/mkdocs-material
copyright: 'Copyright &copy; 2016 - 2017 Martin Donath' copyright: 'Copyright &copy; 2016 - 2017 Martin Donath'
# Theme directory # Theme directory
theme_dir: material theme:
name: null
custom_dir: material
# Same values as in mkdocs_theme.yml
palette:
primary:
accent: blue
plugins:
- search: null
# Options # Options
extra: extra:

View File

@ -18,6 +18,6 @@
# 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.
mkdocs==0.16.3 mkdocs>=0.17
Pygments>=2.2 Pygments>=2.2
pymdown-extensions>=3.4 pymdown-extensions>=3.4

View File

@ -22,6 +22,9 @@
{% import "partials/language.html" as lang with context %} {% import "partials/language.html" as lang with context %}
<!-- Theme options -->
{% set palette = config.theme.palette %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="{{ lang.t('language') }}" class="no-js"> <html lang="{{ lang.t('language') }}" class="no-js">
<head> <head>
@ -105,7 +108,7 @@
href="{{ base_url }}/assets/stylesheets/application.css" /> href="{{ base_url }}/assets/stylesheets/application.css" />
<!-- Extra color palette --> <!-- Extra color palette -->
{% if config.extra.palette %} {% if palette.primary or palette.accent %}
<link rel="stylesheet" type="text/css" <link rel="stylesheet" type="text/css"
href="{{ base_url }}/assets/stylesheets/application.palette.css" /> href="{{ base_url }}/assets/stylesheets/application.palette.css" />
{% endif %} {% endif %}
@ -148,12 +151,17 @@
</head> </head>
<!-- Integrate color palette, if defined --> <!-- Integrate color palette, if defined -->
{% set palette = config.extra.get("palette", {}) %} {% if palette.primary or palette.accent %}
{% set primary = palette.primary | replace(" ", "-") | lower %} {% set primary = palette.primary | replace(" ", "-") | lower %}
{% set accent = palette.accent | replace(" ", "-") | lower %} {% set accent = palette.accent | replace(" ", "-") | lower %}
{% if primary or accent %} {% if palette.primary and palette.accent %}
<body data-md-color-primary="{{ primary }}" <body data-md-color-primary="{{ primary }}"
data-md-color-accent="{{ accent }}"> data-md-color-accent="{{ accent }}">
{% elif palette.primary %}
<body data-md-color-primary="{{ primary }}">
{% elif palette.accent %}
<body data-md-color-accent="{{ accent }}">
{% endif %}
{% else %} {% else %}
<body> <body>
{% endif %} {% endif %}

View File

@ -18,6 +18,24 @@
# 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.
# 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:
# Primary color used for header, sidebar and links, default: indigo
primary:
# Accent color for highlighting user interaction, default: indigo
accent:
# 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
# Material doesn't use MkDocs search functionality but provides its own. For
# this reason, only the search index needs to be built
search_index_only: true
# Static pages to build # Static pages to build
static_templates: static_templates:
- 404.html - 404.html