You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

198 lines
9.4 KiB
HTML

2 years ago
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{# Site title #}
<title>{%- include "partials/title.html" -%}</title>
2 years ago
{# Favicon #}
{% if config.extra.favicon %}
<link rel="icon" type="image/png" href="{{ get_url(path=config.extra.favicon) }}"/>
2 years ago
{% endif %}
{% if config.extra.favicon_emoji %}
<link rel=icon href='data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg" viewBox="0 0 105 55"><text y=".7em" font-size="90">{{ config.extra.favicon_emoji }}</text></svg>'>
{% endif %}
2 years ago
{# Feed #}
<link rel="alternate" type="application/atom+xml" title="{{ config.title | safe }}" href="{{ get_url(path="atom.xml",
2 years ago
trailing_slash=false) }}">
{# CSS #}
{# Load subset of glyphs for header. Avoids flashing issue in Firefox #}
{% if config.extra.custom_subset and config.extra.custom_subset == true %}
<link rel="stylesheet" href={{ get_url(path="custom_subset.css" ) }}>
{% elif lang == 'en' %}
<link rel="stylesheet" href={{ get_url(path="inter_subset_en.css" ) }}>
{% elif lang == 'es' %}
<link rel="stylesheet" href={{ get_url(path="inter_subset_es.css" ) }}>
{% 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 -%}
2 years ago
{# Load extra CSS for custom skin #}
{%- if config.extra.skin and config.extra.skin != "teal" -%}
{%- set stylesheets = stylesheets | concat(with='skins/' ~ config.extra.skin ~ '.css') -%}
{%- endif -%}
2 years ago
{# 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 | striptags | safe }}" />
<meta property="og:description" content="{{ page.description | striptags | safe }}" />
{%- elif page.summary %}
<meta name="description" content="{{ page.summary | striptags | safe | trim_end_matches(pat=".") }}" />
<meta property="og:description" content="{{ page.summary | striptags | safe | trim_end_matches(pat=".") }}" />
{%- else %}
<meta name="description" content="{{ config.description }}" />
<meta property="og:description" content="{{ config.description }}" />
{%- endif %}
2 years ago
{% if is_404 %}
<meta name="robots" content="noindex, follow" />
2 years ago
{% else %}
<meta name="robots" content="index, nofollow" />
2 years ago
{% endif %}
<meta property="og:title" content="{{ page.title | default(value=config.title) | safe }}" />
2 years ago
<meta property="og:type" content="article" />
{# 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 %}
{# Image for social media sharing #}
{%- set social_media_card = macros_settings::evaluate_setting_priority(setting="social_media_card", page=page | default(value=""), section=section | default(value=""), default_global_value="") -%}
{% if social_media_card %}
{# Try to construct the image path relative to the current page #}
{% set colocated_path = page.colocated_path | default(value="") %}
{% set file_path = colocated_path ~ social_media_card %}
{# Fetch metadata to verify image existence at the relative path #}
{%- set meta = get_image_metadata(path=file_path, allow_missing=true) -%}
{# Check if relative path exists, else try absolute path #}
{% if meta %}
{% set final_path = file_path %}
{% else %}
{# If the relative path didn't work, try fetching metadata for the absolute path #}
{% set meta = get_image_metadata(path=social_media_card, allow_missing=true) %}
{% if meta %}
{% set final_path = social_media_card %}
{% else %}
{# Throw an error if the image doesn't exist at either path #}
{{ throw(message="Could not get metadata for the specified social media card image in page " ~ page.path ~ ". Attempted relative path: '" ~ file_path ~ "' and absolute path: '" ~ social_media_card ~ "'. Ensure the file exists at one of these locations.") }}
{% endif %}
{% endif %}
{# Generate the social media meta tags #}
<meta property="og:image" content="{{ get_url(path=final_path, cachebust=true) }}" />
<meta property="og:image:width" content="{{ meta.width }}" />
<meta property="og:image:height" content="{{ meta.height }}" />
<meta name="twitter:image" content="{{ get_url(path=final_path, cachebust=true) }}" />
<meta name="twitter:card" content="summary_large_image" />
2 years ago
{% endif %}
{%- if current_url -%}
<meta property="og:url" content="{{ current_url }}">
{%- endif -%}
2 years ago
<meta property="og:site_name" content="{{ config.title }}">
<meta http-equiv="Content-Security-Policy"
content="default-src 'self'
{%- if config.extra.allowed_domains -%}
;
{#- Check if a comment system is enabled to allow the necessary domains and directives -#}
{%- set utterances_enabled = config.extra.utterances.enabled_for_all_posts or page.extra.utterances -%}
{%- set giscus_enabled = config.extra.giscus.enabled_for_all_posts or page.extra.giscus -%}
{%- set hyvortalk_enabled = config.extra.hyvortalk.enabled_for_all_posts or page.extra.hyvortalk -%}
{%- set isso_enabled = config.extra.isso.enabled_for_all_posts or page.extra.isso -%}
{#- Initialise a base connect-src directive -#}
{%- set connect_src = "connect-src 'self'" -%}
{%- if hyvortalk_enabled -%}
{%- set connect_src = connect_src ~ " talk.hyvor.com" -%}
{%- elif isso_enabled -%}
{%- set connect_src = connect_src ~ " " ~ config.extra.isso.endpoint_url -%}
{%- endif -%}
{#- Append WebSocket for Zola serve mode -#}
{%- if config.mode == "serve" -%}
{%- set connect_src = connect_src ~ " ws:" -%}
{%- endif -%}
{%- for domain in config.extra.allowed_domains -%}
{%- if domain.directive == "connect-src" -%}
{%- set configured_connect_src = domain.domains | join(sep=' ') -%}
{%- set_global connect_src = connect_src ~ " " ~ configured_connect_src -%}
{%- continue -%}
{%- endif -%}
{#- Handle directives that are not connect-src -#}
{{ domain.directive }} {{ domain.domains | join(sep=' ') -}}
{% if utterances_enabled or hyvortalk_enabled -%}
{%- if domain.directive == "style-src" %} 'unsafe-inline'
{%- endif -%}
{% endif -%}
{%- if domain.directive == "script-src" or domain.directive == "frame-src" -%}
{%- if giscus_enabled %} giscus.app
{%- elif utterances_enabled %} utteranc.es
{%- elif hyvortalk_enabled %} talk.hyvor.com
{%- endif %}
{%- endif -%}
{%- if domain.directive == "script-src" -%}
{%- if isso_enabled %} {{ config.extra.isso.endpoint_url }}
{%- endif %}
{%- endif -%}
{%- if not loop.last -%}
;
{%- endif -%}
{%- endfor -%}
{#- Insert the generated connect-src -#}
{{ ";" ~ connect_src }}
{%- endif -%}">
{%- 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 -%}
</head>