softinio.com/templates/partials/header.html
Salar Rahmanian b5751ff524
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful
update theme and configure search
2024-02-17 14:12:17 -08:00

195 lines
9.6 KiB
HTML

<head>
<meta charset="UTF-8">
<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="{{ get_url(path=config.extra.favicon_emoji, trailing_slash=false) | safe }}">
{% endif %}
{# Feed #}
<link rel="alternate" type="application/atom+xml" title="{{ config.title | safe }}" href="{{ get_url(path="atom.xml",
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" , 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 %}
{# 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 }}" />
<meta name="twitter: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 | 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 }}" />
<meta name="twitter:description" content="{{ config.description}}" />
{%- endif %}
{% if is_404 %}
<meta name="robots" content="noindex, follow" />
{% else %}
<!-- <meta name="robots" content="index, nofollow" /> -->
<meta name="robots" content="index, follow" />
<meta name="googlebot" content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1" />
<meta name="bingbot" content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1" />
{% endif %}
<meta property="og:title" content="{{ page.title | default(value=config.title) | safe }}" />
<meta property="og:type" content="article" />
{# 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" />
{% endif %}
{# 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 }}" />
<meta name="twitter:url" content="{{ current_url }}" />
{%- endif -%}
<meta property="og:site_name" content="{{ config.title }}">
{%- include "partials/content_security_policy.html" -%}
{%- 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 -%}
{# 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 -%}
{%- include "partials/custom_header.html" -%}
</head>