-
Notifications
You must be signed in to change notification settings - Fork 1
/
base.njk
142 lines (110 loc) · 4.94 KB
/
base.njk
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
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#173854"/>
<link rel="shortcut icon" href="/assets/favicon/favicon.ico" type="image/vnd.microsoft.icon" />
{# ---- Optimal/non-blocking way to load Google Font (Reference: https://csswizardry.com/2020/05/the-fastest-google-fonts) ---- #}
{% if website.google_font_url %}
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
{# Less optimized method but less FOUT: #}
{# <link rel="stylesheet" href="{{ website.google_font_url }}" /> #}
{# More optimized method but more FOUT: #}
<link rel="preload" as="style" href="{{ website.google_font_url }}" />
<link rel="stylesheet" href="{{ website.google_font_url }}" media="print" onload="this.media='all'" />
{# Ignoring <noscript> for normal font load when Javascript is disabled. Fallback font will be used #}
{% endif %}
{# SEO... #}
<title>{{ title and title + ' | ' }}{{ section_title + ' | ' if section_title else '' }}{{ website.author }}</title>
<meta name="description" content="{{ (description or website.description) | truncate(150) }}">
<meta name="keywords" content="{{ keywords or website.keywords }}, {{ website.title }}">
{# OpenGraph Social Card #}
<meta property="og:title" content="{{ title }}">
<meta property="og:description" content="{{ description or website.description }}">
<meta property="og:image" content="{{ env.BASE_URL }}{% if generate_social_image -%}{% GenerateSocialImage title, website.title %}{%- else -%}{% SocialImagePath image or website.image %}{%- endif %}">
<meta property="og:type" content="website">
<meta property="og:url" content="{{ env.BASE_URL }}{{ page.url }}">
<meta property="og:site_name" content="{{ website.title }}">
{# Twitter Social Card #}
<meta name="twitter:title" content="{{ title }}">
<meta name="twitter:description" content="{{ description or website.description }}">
<meta name="twitter:image" content="{{ env.BASE_URL }}{% if generate_social_image -%}{% GenerateSocialImage title, website.title %}{%- else -%}{% SocialImagePath image or website.image %}{%- endif %}">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:url" content="{{ env.BASE_URL }}{{ page.url }}">
<meta name="twitter:site" content="{{ website.twitter_handle }}">
{# RSS Atom Feed #}
<link rel="alternate" href="{{ env.BASE_URL }}/feed.xml" type="application/atom+xml"
title="{{ website.sections.feed.title }} | {{ website.author }}" />
{# WebMentions #}
{% if website.webmentions.domain and env.WEBMENTION_IO_TOKEN %}
<link rel="webmention" href="https://webmention.io/{{ website.webmentions.domain }}/webmention" />
<link rel="pingback" href="https://webmention.io/{{ website.webmentions.domain }}/xmlrpc" />
{% endif %}
{% block head %}{% endblock %}
{# DEFINE Main CSS Files (common to all sections & pages) #}
{% set css_main %}
{% include "css/flex.css" %}
{% include "css/base.css" %}
{% include "css/header.css" %}
{% include "css/footer.css" %}
{% endset %}
{# DEFINE CSS Files for Home page #}
{% set css_home %}
{% include "css/home.css" %}
{% endset %}
{# DEFINE CSS for Blog and note #}
{% set css_blog %}
{% include "css/blog.css" %}
{% include "css/syntaxhighlight/prism-material-dark.css" %}
{% endset %}
{% set css_bloglist %}
{% include "css/bloglist.css" %}
{% endset %}
{% set css_noteslist %}
{% include "css/noteslist.css" %}
{% endset %}
{% set css_notes %}
{% include "css/notes.css" %}
{% endset %}
{# DEFINE Main Javascript files #}
{% set js_main %}
{% include "js/base.js" %}
{% endset %}
<style>
{{ css_main | cssmin | safe }}
{% block custom_style %}{% endblock %}
</style>
</head>
<body>
{% include "header.njk" %}
<main>
{% block main%}{% endblock %}
</main>
{% include "footer.njk" %}
{% set netlify_cms %}
{% include "js/netlify_cms.js" %}
{% endset %}
<script>
{{ js_main | jsmin | safe }}
{{ netlify_cms | jsmin | safe }}
</script>
{# ~~~~~ Global site tag (gtag.js) - Google Analytics ~~~~~ #}
{% if env.GA_KEY %}
{% set google %}
{% include "js/google_analytics.js" %}
{% endset %}
<script>
{{ google | jsmin | safe }}
googleAnalytics('{{ env.GA_KEY }}');
addLoadEvent(function() { loadScript("https://www.googletagmanager.com/gtag/js?id={{ env.GA_KEY }}", null, null, true); });
</script>
{% endif %}
{# ~~~~~ Microsoft Clarity (Analytics) ~~~~~ #}
{% if env.MS_CLARITY_TAG %}
<script>addLoadEvent(function(){(function(c,l,a,r,i,t,y){c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);})(window, document, "clarity", "script", "{{ env.MS_CLARITY_TAG }}");})</script>
{% endif %}
{# ~~~~~~~~ custom script placeholder for other pages ~~~~~~~~ #}
<script>{% block custom_script %}{% endblock %}</script>
</body>
</html>