summaryrefslogtreecommitdiff
path: root/sysret.org/themes/tabi-lean/templates/partials/header.html
blob: ada1f23aa336c794d6531b017543d78367500070 (plain)
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<head>
    <meta charset="UTF-8">

    {%- if macros_settings::evaluate_setting_priority(setting="enable_csp", page=page | default(value=""), section=section | default(value=""), default_global_value="true") == "true" -%}
        {%- include "partials/content_security_policy.html" -%}
    {%- endif -%}

    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="base" content="{{ config.base_url | safe }}">

    {# Site title #}
    <title>{%- include "partials/title.html" -%}</title>

    {# Favicon #}
    {% if config.extra.favicon %}
        <link rel="icon" type="image/png" href="{{ get_url(path=config.extra.favicon) }}"/>
    {% endif %}
    {% if config.extra.favicon_emoji %}
        <link rel=icon href='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y="50%" x="50%" dominant-baseline="central" text-anchor="middle" font-size="88">{{ config.extra.favicon_emoji }}</text></svg>'>
    {% endif %}

    {# Feeds #}
    {% if config.generate_feeds | default(value=config.generate_feed) %}
        {% if config.feed_filenames %}
            {# Zola 0.19 and newer #}
            {% for feed in config.feed_filenames %}
                {% if feed == "atom.xml" %}
                    <link rel="alternate" type="application/atom+xml" title="{{ config.title | safe }} - Atom Feed" href="{{ get_url(path=feed, trailing_slash=false) | safe }}">
                {% elif feed == "rss.xml" %}
                    <link rel="alternate" type="application/rss+xml" title="{{ config.title | safe }} - RSS Feed" href="{{ get_url(path=feed, trailing_slash=false) | safe }}">
                {% else %}
                    <link rel="alternate" href="{{ get_url(path=feed, trailing_slash=false) | safe }}">
                {% endif %}
            {% endfor %}
        {% else %}
            {# Older Zola versions #}
            {% set feed_url = config.feed_filename | default(value="atom.xml") %}
            <link rel="alternate" type="application/atom+xml" title="{{ config.title | safe }}" href="{{ get_url(path=feed_url, trailing_slash=false) | safe }}">
        {% endif %}
    {% endif %}

    {# CSS #}
    {# Load subset of glyphs for header. Avoids flashing issue in Firefox #}
    {% if config.extra.enable_subset %}
        {% if config.extra.custom_subset == true %}
            <link rel="stylesheet" href="{{ get_url(path="custom_subset.css" , cachebust=true) }}">
        {% elif lang == 'en' %}
            <link rel="stylesheet" href="{{ get_url(path="inter_subset_en.css", cachebust=true ) }}">
        {% elif lang == 'es' %}
            <link rel="stylesheet" href="{{ get_url(path="inter_subset_es.css", cachebust=true ) }}">
        {% endif %}
    {% endif %}

    {# Define array of CSS files to load. main.css is always loaded. #}
    {%- set stylesheets = [ "main.css" ] -%}

    {# Load extra CSS files from config.toml #}
    {%- if config.extra.stylesheets -%}
        {%- set stylesheets = stylesheets | concat(with=config.extra.stylesheets) -%}
    {%- endif -%}

    {# Load extra CSS files from page metadata #}
    {%- if page.extra.stylesheets -%}
        {%- set stylesheets = stylesheets | concat(with=page.extra.stylesheets) -%}
    {%- endif -%}

    {# Load extra CSS for custom skin #}
    {%- if config.extra.skin -%}
        {%- set stylesheets = stylesheets | concat(with='skins/' ~ config.extra.skin ~ '.css') -%}
    {%- endif -%}

    {# Load all stylesheets #}
    {%- for stylesheet in stylesheets %}
        <link rel="stylesheet" href="{{ get_url(path=stylesheet, cachebust=true) | safe }}" />
    {%- endfor %}

    <meta name="color-scheme" content="{%- if config.extra.theme_switcher -%}light dark{%- elif config.extra.default_theme -%}{{config.extra.default_theme}}{%- else -%}light{%- endif -%}" />

    {%- if config.extra.browser_theme_color and config.extra.browser_theme_color is iterable -%}
        {# Handle array values: theme_color[0] for light mode, theme_color[1] for dark mode #}
        <meta name="theme-color" media="(prefers-color-scheme: light)" content="{{ config.extra.browser_theme_color[0] }}" />
        <meta name="theme-color" media="(prefers-color-scheme: dark)" content="{{ config.extra.browser_theme_color[1] }}" />
    {%- elif config.extra.browser_theme_color -%}
        {# Handle single value #}
        <meta name="theme-color" content="{{ config.extra.browser_theme_color }}" />
    {%- endif -%}

    {%- if page.description %}
        <meta name="description" content="{{ page.description }}" />
        <meta property="og:description" content="{{ page.description }}" />
    {%- elif section.description %}
        <meta name="description" content="{{ section.description }}" />
        <meta property="og:description" content="{{ section.description }}" />
    {%- elif page.summary %}
        <meta name="description" content="{{ page.summary | striptags | trim_end_matches(pat=".") | safe }}…" />
        <meta property="og:description" content="{{ page.summary | striptags | trim_end_matches(pat=".") | safe }}…" />
    {%- else %}
        <meta name="description" content="{{ config.description }}" />
        <meta property="og:description" content="{{ config.description }}" />
    {%- endif %}

    {% if is_404 %}
        <meta name="robots" content="noindex, follow" />
    {% endif %}

    <meta property="og:title" content="{{ page.title | default(value=config.title) | safe }}" />
    <meta property="og:type" content="article" />

    {# Image for social media sharing #}
    {%- include "partials/social_media_images.html" -%}

    {# Add og:locale and hreflang tags for multilingual sites #}
    {%- if config.languages | length > 0 and current_url %}
        {%- include "partials/multilingual_tags.html" -%}
    {%- else -%}
        <meta property="og:locale" content="{{ macros_translate::translate(key="date_locale", default="en_GB", language_strings=language_strings) }}" />
    {%- endif %}

    {# Set canonical URL #}
    {%- if current_url -%}
        {%- if page.extra.canonical_url or section.extra.canonical_url -%}
            {%- set canonical_url = page.extra.canonical_url | default(value=section.extra.canonical_url) -%}
        {%- elif config.extra.base_canonical_url -%}
            {%- set canonical_url = current_url | replace(from=config.base_url, to=config.extra.base_canonical_url) -%}
        {%- endif -%}
    {%- endif -%}

    {# Add canonical URL, if set #}
    {%- if canonical_url -%}
        <link rel="canonical" href="{{ canonical_url }}" />
        <meta property="og:url" content="{{ canonical_url }}" />
    {%- elif current_url -%}
        <meta property="og:url" content="{{ current_url }}" />
    {%- endif -%}

    <meta property="og:site_name" content="{{ config.title }}">

    {%- if config.extra.theme_switcher and config.extra.theme_switcher == true -%}
        {# If JavaScript is disabled, hide the button. #}
        <noscript><link rel="stylesheet" href="{{ get_url(path='no_js.css') | safe }}"/></noscript>
        <script type="text/javascript" src="{{ get_url(path='js/initializeTheme.min.js') | safe }}"></script>
        <script defer src="{{ get_url(path='js/themeSwitcher.min.js', trailing_slash=false) | safe }}"></script>
    {%- endif -%}

    {%- if config.extra.analytics.service -%}
        {%- include "partials/analytics.html" -%}
    {%- endif -%}

    {# Socials #}
    {%- if config.extra.fediverse_creator -%}
        <meta name="fediverse:creator" content="@{{ config.extra.fediverse_creator["handle"] }}@{{ config.extra.fediverse_creator["domain"]}}" />
    {%- endif -%}

    {# Search #}
    {%- if config.build_search_index -%}
        {%- if config.search.index_format -%}
            {%- set search_index_format = config.search.index_format -%}
        {%- elif config.extra.index_format -%}
            {# Necessary to support Zola 0.17.X, as it doesn't have access to config.search.index_format #}
            {# See: https://github.com/getzola/zola/issues/2165 #}
            {%- set search_index_format = config.extra.index_format -%}
        {%- else -%}
            {%- set search_index_format = "elasticlunr_json" -%}
        {%- endif -%}

        {%- if search_index_format == "elasticlunr_javascript" -%}
            <script defer src="{{ get_url(path='search_index.' ~ lang ~ '.js', cachebust=true) | safe }}"></script>
        {%- endif -%}

        {# Main search script #}
        <script defer src="{{ get_url(path='js/searchElasticlunr.min.js', cachebust=true) | safe }}"></script>

        {# Support correct stemming and stop word filtering in non-English search #}
        {%- if lang != "en" -%}
            <script defer src="{{ get_url(path='js/lunr/lunrStemmerSupport.min.js') | safe }}"></script>
            <script defer src="{{ get_url(path='js/lunr/lunr.' ~ lang ~ '.min.js') | safe }}"></script>
        {%- endif -%}
    {%- endif -%}

    {# Users can optionally provide this template to add content to the head element. #}
    {% include "tabi/extend_head.html" ignore missing %}
</head>