Files
blog/themes/Ying/layouts/partials/head.html
T

180 lines
7.3 KiB
HTML
Raw Normal View History

2024-07-11 08:59:32 +08:00
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>{{ .Title }}</title>
2026-01-22 21:39:19 +08:00
<!-- SEO & Meta Tags -->
<meta name="description" content="{{ if .IsHome }}{{ .Site.Params.description }}{{ else }}{{ .Description | default .Summary | plainify | truncate 160 }}{{ end }}" />
2026-05-20 14:33:05 +08:00
<link rel="canonical" href="{{ .RelPermalink | absURL }}" />
2026-01-22 21:39:19 +08:00
{{- $keywords := slice "大学" "教程" "blog" "优世界" "优设计" "博客" "大学生博客" "生活" "文案" -}}
{{- if .Params.tags -}}
{{- $keywords = .Params.tags -}}
{{- end -}}
{{- if .Params.keywords -}}
{{- $keywords = .Params.keywords -}}
{{- end -}}
<meta name="keywords" content="{{ delimit $keywords "," }}" />
<!-- Open Graph -->
<meta property="og:title" content="{{ .Title }}" />
<meta property="og:description" content="{{ if .IsHome }}{{ .Site.Params.description }}{{ else }}{{ .Description | default .Summary | plainify | truncate 160 }}{{ end }}" />
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
<meta property="og:url" content="{{ .Permalink }}" />
<meta property="og:site_name" content="{{ .Site.Title }}" />
2026-06-04 21:04:27 +08:00
<meta name="nilaila-verify" content="97dd49b8e6e941828e647b11bea73891">
2026-01-22 21:39:19 +08:00
{{- $image := .Site.Params.authorImage -}}
{{- if .Params.cover -}}
{{- $image = .Params.cover -}}
{{- end -}}
{{- if $image -}}
<meta property="og:image" content="{{ $image | absURL }}" />
<meta name="twitter:image" content="{{ $image | absURL }}" />
{{- end -}}
<!-- Twitter Card -->
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="{{ .Title }}" />
<meta name="twitter:description" content="{{ if .IsHome }}{{ .Site.Params.description }}{{ else }}{{ .Description | default .Summary | plainify | truncate 160 }}{{ end }}" />
2024-10-20 11:51:55 +08:00
<!-- RSS Feed -->
2025-04-13 19:08:41 +08:00
<link rel="alternate" type="application/rss+xml" title="{{ site.Title }}" href="/rss.xml">
2024-10-20 11:51:55 +08:00
<!-- Favicon -->
2024-07-11 08:59:32 +08:00
<link rel="icon" type="image/x-icon" href="/favicon.ico">
2026-05-25 13:06:26 +08:00
<!-- Resource Hints -->
<link rel="preconnect" href="https://cravatar.cn">
<link rel="preconnect" href="https://api.usj.cc">
<link rel="dns-prefetch" href="https://bsz.dusays.com:9001">
2026-05-19 09:53:08 +08:00
<!-- Analytics -->
<script async src="https://019e3dec-3312-7873-862a-3f56ac99ea83.spst2.com/ustat.js"></script>
2026-01-18 23:09:07 +08:00
<script>
(function () {
try {
var theme = localStorage.getItem('theme');
if (!theme) {
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
theme = 'dark';
} else {
theme = 'light';
}
}
document.documentElement.setAttribute('data-theme', theme);
2026-01-31 21:27:06 +08:00
// Listen for system changes
if (window.matchMedia) {
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
// Only switch if user hasn't manually set a preference
// Or maybe we should respect system change if user hasn't explicitly locked it?
// Common behavior: manual override sticks.
if (!localStorage.getItem('theme')) {
var newTheme = event.matches ? "dark" : "light";
document.documentElement.setAttribute('data-theme', newTheme);
}
});
}
2026-01-18 23:09:07 +08:00
} catch (e) {}
})();
</script>
2026-01-22 22:33:35 +08:00
<!-- Preload Fonts -->
2026-06-25 15:07:25 +08:00
<link rel="preload" href="{{ "font/zql-v2-subset.woff2" | relURL }}" as="font" type="font/woff2" crossorigin>
2026-06-25 19:07:58 +08:00
<!-- remixicon 不预加载,避免与 CSS 中带 query 参数的 URL 不一致导致警告 -->
2026-01-22 22:33:35 +08:00
2026-05-25 00:03:50 +08:00
{{ $echartsHead := resources.Get "js/libs/echarts.min.js" | resources.Fingerprint }}
{{ $artalkHead := resources.Get "js/libs/Artalk.js" | resources.Fingerprint }}
2026-01-23 22:02:11 +08:00
<!-- Site Configuration -->
<script>
2026-05-25 00:03:50 +08:00
window.optionalAssetUrls = {
echarts: {{ $echartsHead.RelPermalink | jsonify | safeJS }},
artalk: {{ $artalkHead.RelPermalink | jsonify | safeJS }}
};
window.loadScriptOnce = window.loadScriptOnce || function(src, globalName, callback) {
if (globalName && window[globalName]) {
callback();
return;
}
var existing = document.querySelector('script[data-dynamic-src="' + src + '"]');
if (existing) {
existing.addEventListener('load', callback, { once: true });
return;
}
var script = document.createElement('script');
script.src = src;
script.defer = true;
script.dataset.dynamicSrc = src;
script.onload = callback;
document.head.appendChild(script);
};
2026-01-23 22:02:11 +08:00
window.siteConfig = {
artalk: {
server: "{{ .Site.Params.artalk.server }}",
site: "{{ .Site.Params.artalk.site }}",
2026-01-31 23:01:35 +08:00
emoticons: "{{ .Site.Params.artalk.emoticons | absURL }}",
2026-01-23 22:02:11 +08:00
gravatar: "{{ .Site.Params.artalk.gravatar }}"
},
author: {
avatar: "{{ .Site.Params.author.avatar }}",
description: "{{ .Site.Params.author.description }}"
},
barrage: {
enableHitokoto: {{ .Site.Params.barrage.enableHitokoto | default true }},
hitokotoUrl: "{{ .Site.Params.barrage.hitokotoUrl }}"
}
};
</script>
2024-10-20 11:51:55 +08:00
<!-- Stylesheets -->
2026-01-31 23:42:49 +08:00
{{ $normalize := resources.Get "css/libs/normalize.css" }}
{{ $remixicon := resources.Get "css/libs/remixicon.css" }}
{{ $uikit := resources.Get "css/libs/uikit.min.css" }}
{{ $nprogress := resources.Get "css/libs/nprogress.min.css" }}
{{ $message := resources.Get "css/libs/message.min.css" }}
2026-06-25 13:53:18 +08:00
{{ $fontSlices := resources.Get "css/font-slices.css" }}
2026-01-22 21:39:19 +08:00
{{ $main := resources.Get "css/main.css" }}
2026-06-24 17:25:54 +08:00
{{ $shortcodes := resources.Get "css/shortcodes.css" }}
2026-01-22 21:39:19 +08:00
2026-06-25 13:53:18 +08:00
{{ $style := slice $normalize $remixicon $uikit $nprogress $message $fontSlices $main $shortcodes | resources.Concat "css/style.css" | resources.Minify | resources.Fingerprint }}
2026-01-22 21:39:19 +08:00
<link rel="stylesheet" href="{{ $style.RelPermalink }}">
2026-01-22 22:33:35 +08:00
{{- if and .Site.Params.style.enableBackgroundImage .Site.Params.style.backgroundImageUrl -}}
<style>
2026-06-22 17:43:52 +08:00
body {
2026-01-22 22:33:35 +08:00
background-image: url('{{ .Site.Params.style.backgroundImageUrl }}') !important;
background-size: {{ .Site.Params.style.backgroundSize | default "cover" }} !important;
background-repeat: {{ .Site.Params.style.backgroundRepeat | default "no-repeat" }} !important;
background-position: {{ .Site.Params.style.backgroundPosition | default "center" }} !important;
background-attachment: {{ .Site.Params.style.backgroundAttachment | default "fixed" }} !important;
}
2026-06-22 17:43:52 +08:00
[data-theme="dark"] body {
2026-06-24 20:22:40 +08:00
background-image: url(/image/background/deno.webp) !important;
background-size: contain !important;
background-repeat: round !important;
background-position: center !important;
background-attachment: fixed !important;
}
[data-theme="dark"] body::before {
content: '' !important;
position: fixed !important;
top: 0 !important;
left: 0 !important;
width: 100% !important;
height: 100% !important;
background-color: rgba(0, 0, 0, 0.4) !important;
pointer-events: none !important;
z-index: -1 !important;
2026-06-22 17:43:52 +08:00
}
2026-05-25 00:03:50 +08:00
@media (max-width: 768px) {
2026-06-22 17:43:52 +08:00
body {
2026-05-25 00:03:50 +08:00
background-attachment: scroll !important;
}
}
2026-01-22 22:33:35 +08:00
</style>
{{- end -}}
2026-01-31 19:24:22 +08:00
<!-- <script src="/js/jquery.min.js"></script> -->
2026-01-26 23:09:57 +08:00
2026-01-22 20:07:43 +08:00
2024-07-30 12:57:30 +08:00
<script src="/js/instantpage.min.js" type="module" defer></script>
2024-07-28 21:17:19 +08:00
<meta name="template" content="Amigo" />
2026-01-18 23:09:07 +08:00
</head>