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(),
mqpacker
].concat(!args.optimize ? [
pseudoclasses({
"restrictTo": ["hover", "focus"]
})
// pseudoclasses({
// "restrictTo": ["hover", "focus"]
// })
] : [])))
/* Minify sources */

View File

@ -39,7 +39,9 @@ export default () => {
server.kill()
/* 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"
})
}

View File

@ -1,4 +1,5 @@
{% import "partials/language.html" as lang with context %}
{% set palette = config.theme.palette %}
<!DOCTYPE html>
<html lang="{{ lang.t('language') }}" class="no-js">
<head>
@ -51,7 +52,7 @@
{% endblock %}
{% block styles %}
<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">
{% endif %}
{% endblock %}
@ -71,11 +72,16 @@
{% endfor %}
{% block extrahead %}{% endblock %}
</head>
{% set palette = config.extra.get("palette", {}) %}
{% set primary = palette.primary | replace(" ", "-") | lower %}
{% set accent = palette.accent | replace(" ", "-") | lower %}
{% if primary or accent %}
<body data-md-color-primary="{{ primary }}" data-md-color-accent="{{ accent }}">
{% if palette.primary or palette.accent %}
{% set primary = palette.primary | replace(" ", "-") | lower %}
{% set accent = palette.accent | replace(" ", "-") | lower %}
{% if palette.primary and palette.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 %}
<body>
{% endif %}

View File

@ -14,6 +14,19 @@
# 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.
# 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_templates:
- 404.html

View File

@ -32,7 +32,17 @@ repo_url: https://github.com/squidfunk/mkdocs-material
copyright: 'Copyright &copy; 2016 - 2017 Martin Donath'
# 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
extra:

View File

@ -18,6 +18,6 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
mkdocs==0.16.3
mkdocs>=0.17
Pygments>=2.2
pymdown-extensions>=3.4

View File

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

View File

@ -18,6 +18,24 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# 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_templates:
- 404.html