friendenstein/templates/head.html

136 lines
6.3 KiB
HTML
Raw Normal View History

2024-01-02 12:18:18 +01:00
{% import "macros/marginals.html" as marginals %}
<meta charset="UTF-8">
<meta content="IE=edge" http-equiv="X-UA-Compatible"/>
<meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<meta name="robots" content="index, follow">
{% if page.title %}
2024-01-02 12:18:18 +01:00
{% set title = page.title %}
{% elif section.title %}
2024-01-02 12:18:18 +01:00
{% set title = section.title %}
{% elif config.title %}
2024-01-02 12:18:18 +01:00
{% set title = config.title %}
{% endif %}
{% if page.extra.author %}
2024-01-02 12:18:18 +01:00
{% set author = page.extra.author %}
{% elif section.extra.author %}
2024-01-02 12:18:18 +01:00
{% set author = section.extra.author %}
{% elif config.extra.author %}
2024-01-02 12:18:18 +01:00
{% set author = config.extra.author %}
{% endif %}
{% if page.description %}
2024-01-02 12:18:18 +01:00
{% set description = page.description | truncate(length=150) %}
{% elif section.description %}
2024-01-02 12:18:18 +01:00
{% set description = section.description | truncate(length=150) %}
{% elif config.description %}
2024-01-02 12:18:18 +01:00
{% set description = config.description | truncate(length=150) %}
{% endif %}
{% if page.extra.image %}
2024-01-02 12:18:18 +01:00
{% set image = get_url(path=page.extra.image, trailing_slash=false) %}
{% elif section.extra.image %}
2024-01-02 12:18:18 +01:00
{% set image = get_url(path=section.extra.image, trailing_slash=false) %}
{% elif config.extra.favicon %}
2024-01-02 12:18:18 +01:00
{% set image = get_url(path=config.extra.favicon, trailing_slash=false) %}
{% endif %}
{% if page.permalink %}
2024-01-02 12:18:18 +01:00
{% set url = page.permalink %}
{% elif section.permalink %}
2024-01-02 12:18:18 +01:00
{% set url = section.permalink %}
{% elif config.base_url %}
2024-01-02 12:18:18 +01:00
{% set url = config.base_url %}
{% endif %}
{% if title %}
2024-01-02 12:18:18 +01:00
{% if title == config.title %}
<title>{{ title }} :: Home</title>
{% else %}
<title>{{config.title }} :: {{ title }}</title>
{% endif %}
{% endif %}
{% block metatags %}
{% if title %}
2024-01-02 12:18:18 +01:00
<meta name="title" content="{{ title }}">
<meta property="og:site_name" content="{{ config.title }}">
<meta property="og:title" content="{{ title }}">
{% endif %}
2024-01-02 12:18:18 +01:00
{% if author %}<meta name="author" content="{{ author }}">{% endif %}
{% if description %}
2024-01-02 12:18:18 +01:00
<meta name="description" content="{{ description }}">
<meta property="og:description" content="{{ description }}">
{% endif %}
<meta property="og:type" content="website">
<meta property="og:url" content="{{ url | safe }}">
2024-01-02 12:18:18 +01:00
{% if image %}<meta property="og:image" content="{{ image }}">{% endif %}
{% set twitter_card = config.extra.twitter_card | default(value=true) %}
{% if twitter_card != false %}
2024-01-02 12:18:18 +01:00
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="{{ url | safe }}">
{% if title %}<meta property="twitter:title" content="{{ title }}">{% endif %}
{% if description %}<meta property="twitter:description" content="{{ description }}">{% endif %}
{% if image %}<meta property="twitter:image" content="{{ image }}">{% endif %}
{% endif %}
<link rel="canonical" href="{{ url | safe }}">
2024-01-02 12:18:18 +01:00
{% if image %}<link rel="shortcut icon" type="image/x-icon" href="{{ get_url(path=config.extra.favicon, trailing_slash=false) }}">{% endif %}
2023-12-22 12:19:19 +01:00
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
{% endblock metatags %}
{% block feed %}
2024-01-02 12:18:18 +01:00
{% if config.generate_feed %}<link rel="alternate" type="application/atom+xml" title="RSS" href="{{ get_url(path="atom.xml", trailing_slash=false) }}">{% endif %}
{% endblock feed %}
{% block css %}
2023-12-24 19:09:35 +01:00
<style>
:root,
:root.dark {
--bgColor: {% if config.extra.colors.dark.background_color %}{{ config.extra.colors.dark.background_color }}{% else %}#222529{% endif %};
--fgColor: {% if config.extra.colors.dark.foreground_color %}{{ config.extra.colors.dark.foreground_color }}{% else %}#D6D6D6{% endif %};
--metaColor: {% if config.extra.colors.dark.meta_color %}{{ config.extra.colors.dark.meta_color }}{% else %}#78B6AD{% endif %};
--linkColor: {% if config.extra.colors.dark.link_color %}{{ config.extra.colors.dark.link_color }}{% else %}#DBD5BC{% endif %};
--darkLinkColor: {% if config.extra.colors.dark.dark_link_color %}{{ config.extra.colors.dark.dark_link_color }}{% else %}#6F6847{% endif %};
2023-12-25 00:41:54 +01:00
--codeLineColor: {% if config.extra.colors.dark.code_line_color %}{{ config.extra.colors.dark.code_line_color }}{% else %}#31333d{% endif %};
2023-12-24 19:09:35 +01:00
}
:root.light {
--bgColor: {% if config.extra.colors.light.background_color %}{{ config.extra.colors.light.background_color }}{% else %}#EEEEEE{% endif %};
--fgColor: {% if config.extra.colors.light.foreground_color %}{{ config.extra.colors.light.foreground_color }}{% else %}#41474E{% endif %};
--metaColor: {% if config.extra.colors.light.meta_color %}{{ config.extra.colors.light.meta_color }}{% else %}#D26878{% endif %};
--linkColor: {% if config.extra.colors.light.link_color %}{{ config.extra.colors.light.link_color }}{% else %}#5690AF{% endif %};
--darkLinkColor: {% if config.extra.colors.light.dark_link_color %}{{ config.extra.colors.light.dark_link_color }}{% else %}#223844{% endif %};
2023-12-26 03:37:28 +01:00
--codeLineColor: {% if config.extra.colors.light.code_line_color %}{{ config.extra.colors.light.code_line_color }}{% else %}#FFFFFF{% endif %};
2023-12-24 19:09:35 +01:00
}
</style>
2023-12-26 13:06:27 +01:00
{% if config.markdown.highlight_code and config.markdown.highlight_theme == "css" %}
2024-01-02 12:18:18 +01:00
<link id="syntaxHighlighting" rel="stylesheet" type="text/css" href="{{ get_url(path='ayu-dark.css', trailing_slash=false) | safe }}" />
2023-12-26 13:06:27 +01:00
{% endif %}
2023-12-24 18:29:23 +01:00
<link rel="stylesheet" href="{{ get_url(path='style.css', trailing_slash=false) | safe }}"/>
2023-10-06 00:02:23 +02:00
{% endblock css %}
<script>
const setTheme = (theme) => {
2023-12-26 01:11:47 +01:00
document.documentElement.className = theme;
localStorage.setItem('theme', theme);
2023-12-26 03:37:28 +01:00
var link = document.getElementById('syntaxHighlighting');
2023-12-26 13:06:27 +01:00
var shouldLoadSyntax = {% if config.markdown.highlight_code and config.markdown.highlight_theme == "css" %}true{% else %}false{% endif %};
2023-12-26 03:37:28 +01:00
if (theme === 'light') {
2024-01-02 02:31:44 +01:00
link.setAttribute('href', {% if config.extra.colors.light.hightlighting %}'{{ get_url(path=config.extra.colors.light.hightlighting) | safe }}'{% else %}'{{ get_url(path="hl-light.css") | safe }}'{% endif %});
2023-12-26 03:37:28 +01:00
} else if (theme === 'dark') {
2024-01-02 02:31:44 +01:00
link.setAttribute('href', {% if config.extra.colors.dark.hightlighting %}'{{ get_url(path=config.extra.colors.dark.hightlighting) | safe }}'{% else %}'{{ get_url(path="hl-dark.css") | safe }}'{% endif %});
2023-12-26 03:37:28 +01:00
}
}
const hasCodeRun = localStorage.getItem('hasCodeRun');
if (!hasCodeRun) {
2023-12-26 01:11:47 +01:00
const defaultTheme = "{{ config.extra.default_theme }}";
setTheme(defaultTheme);
localStorage.setItem('hasCodeRun', 'true');
}
const getTheme = () => {
2023-12-26 01:11:47 +01:00
const theme = localStorage.getItem('theme');
if (theme) {
setTheme(theme);
}
}
getTheme();
</script>