-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnype-base.html
121 lines (107 loc) · 5.1 KB
/
nype-base.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
{% extends "base.html" -%}
{# The nype_tweaks does some config.theme value modification / validation. Best to force the usage. #}
{% if "nype/nype_tweaks" not in config.plugins %}
{% if {}.__getitem__('ERROR: The nype_tweaks plugin is required to run the nype theme. Please enable it in mkdocs.yml') %}{% endif %}
{% endif %}
{# Fallback for setting the is_serve status #}
{% if config.theme.is_serve is none %}
{% set _ = config.theme.update({ 'is_serve': config.site_url.split('//')[1].split(':')[0] in ['127.0.0.1', 'localhost'] }) %}
{% endif%}
{# Add special debug values for local testing #}
{% if config.theme.is_serve -%}
{% set _ = page_nype_config.js.update({ 'debug_form_hex': '6148523063484d364c79396d62334a74637935316269317a6447463061574d75593239744c325a76636d317a4c7a4a694e3251785a6a6b785a6a677a4f546b7a4d7a55774e6a6732595755324d6d51314d544a6b597a59325a6a5179595467314d6d593d' }) %}
{% endif %}
{% block site_meta -%}
{{- super() -}}
{% block nype_favicon -%}
{# Based on https://dev.to/masakudamatsu/favicon-nightmare-how-to-maintain-sanity-3al7 #}
{% if theme_nype_config.more_favicons -%}
<link rel="icon" href="/favicon.svg" sizes="any" type="image/svg+xml">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<link rel="manifest" href="/site.webmanifest">
{% if theme_nype_config.safari_mask_color %}
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="{{ theme_nype_config.safari_mask_color }}">
{% endif %}
{%- endif %}
{%- endblock -%}
{% block nype_robots -%}
{% if meta_config.robots_content -%}
{%- set robots_content = meta_config.robots_content -%}
{% else %}
{%- set robots_content = "index, follow" -%}
{% endif %}
<meta property="robots" content="{{ robots_content }}">
{%- endblock %}
{%- endblock -%}
{% block styles -%}
{{- super() -}}
{# This is done like this to support minifaction in __main__.py #}
{% set available_css = {
'neoteroi': 'assets/stylesheets/neoteroi.css' | url
} %}
{# Include additional CSS based on the page settings #}
{% if meta_config.css_include -%}
{% for name in meta_config.css_include.split() -%}
{% set name = name.lower() %}
{% set value = available_css.get(name) %}
{% if not value and {}.__getitem__('ERROR: The value for available_css.' ~ name ~ ' is undefined. File: ' ~ page.file.src_uri) %}
{% endif %}
<link rel="stylesheet" href="{{ value }}">
{% endfor %}
{% endif %}
{#- nype-main.css should come after mkdocs-material and all other CSS modules to allow for overrides.
The extra.css styles are loaded later, so nype-main.css can be overridden too. -#}
<link rel="stylesheet" href="{{ 'assets/stylesheets/nype-main.css' | url }}">
{%- endblock -%}
{% block extrahead -%}
{#- Set tags with external assets. Mostly for usage in plugins like latest_blog_post -#}
{%- if page_nype_config.head_tags -%}
{%- for head_tag in page_nype_config.head_tags -%}
<{{ head_tag.name -}}
{%- for attr_name, attr_value in head_tag.attributes.items() %}
{% if attr_value -%}
{{ attr_name }}="{{ attr_value }}"{# Whitespace -#}
{% else -%}
{{ attr_name }}{# Whitespace -#}
{% endif -%}
{% endfor -%}
>
{%- if head_tag.name == "script" -%}
</{{ head_tag.name }}>
{% endif %}
{% endfor %}
{% endif %}
<script>
const nypeScriptConfig = JSON.parse('{{ page_nype_config.js | tojson }}');
</script>
{%- endblock -%}
{% block header -%}
{#- Custom helper div to use for CSS selector in extra.css -#}
{% if page and page.file.dest_uri == "index.html" -%}
{% set page_variant = 'nype-home-page' -%}
{%- elif posts -%}
{% set page_variant = 'nype-blog-page' -%}
{%- else -%}
{% set page_variant = 'nype-normal-page' -%}
{%- endif -%}
<style class="nype-header-styles {{ page_variant }}"></style>
{{- super() -}}
{#- Pass the config from the page meta to the CSS styles. Opt-in approach. -#}
{% set container_ns = namespace(css='') -%}
{% if meta_config.container_css -%}
{% for css_name in meta_config.container_css.strip().split() %}
{% set container_ns.css = container_ns.css ~ ' nype-' ~ css_name -%}
{% endfor %}
{% endif -%}
<style class="nype-container-styles{{ container_ns.css }}"></style>
{#- Update page.meta to hide side panels -#}
{% if 'content-only' in container_ns.css -%}
{% set _ = page.meta.update({ 'hide': ['navigation', 'toc']}) %}
{%- endif -%}
{%- endblock %}
{% block scripts -%}
{#- nype-core.js should come before extra.js in projects. In case nype-core.js needs access
to material bundle.js then some solution will need to be implemented TODO -#}
<script src="{{ 'assets/javascripts/nype-core.js' | url }}"></script>
{{- super() -}}
{% endblock %}