PaperModX/layouts/partials/head.html

143 lines
6.0 KiB
HTML

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
{{- if hugo.IsProduction | or (eq site.Params.env "production") }}
<meta name="robots" content="index, follow">
{{- else }}
<meta name="robots" content="noindex, nofollow">
{{- end }}
{{- /* Title */}}
{{- $pageTitle := site.Title }}
{{- if (and .Title (not .IsHome)) }}
{{- $pageTitle = printf "%s | %s" .Title $pageTitle }}
{{- end }}
<title>{{ $pageTitle }}</title>
{{- /* Meta */}}
{{- if .IsHome }}
{{ with site.Params.keywords -}}<meta name="keywords" content="{{- range $i, $e := . }}{{ if $i }}, {{ end }}{{ $e }}{{ end }}">{{ end }}
{{- else }}
<meta name="keywords" content="{{ if .Params.keywords -}}
{{- range $i, $e := .Params.keywords }}{{ if $i }}, {{ end }}{{ $e }}{{ end }} {{- else }}
{{- range $i, $e := .Params.tags }}{{ if $i }}, {{ end }}{{ $e }}{{ end }} {{- end -}}">
{{- end }}
<meta name="description" content="{{- with .Description }}{{ . }}{{- else }}{{- if or .IsPage .IsSection}}
{{- .Summary | default (printf "%s - %s" .Title site.Title) }}{{- else }}
{{- with site.Params.description }}{{ . }}{{- end }}{{- end }}{{- end -}}">
<meta name="author" content="{{ (partial "author.html" . ) }}">
<link rel="canonical" href="{{ if .Params.canonicalURL -}} {{ trim .Params.canonicalURL " " }} {{- else -}} {{ .Permalink }} {{- end }}">
{{- if site.Params.analytics.googlesiteVerificationTag }}
<meta name="google-site-verification" content="{{ site.Params.analytics.googlesiteVerificationTag }}">
{{- end }}
{{- if site.Params.analytics.yandexsiteVerificationTag }}
<meta name="yandex-verification" content="{{ site.Params.analytics.yandexsiteVerificationTag }}">
{{- end }}
{{- if site.Params.analytics.bingsiteVerificationTag }}
<meta name="msvalidate.01" content="{{ site.Params.analytics.bingsiteVerificationTag }}">
{{- end }}
{{- /* Styles */}}
{{- $theme_vars := (resources.Get "css/core/theme-vars.css") }}
{{- $reset := (resources.Get "css/core/reset.css") }}
{{- $media := (resources.Get "css/core/zmedia.css") }}
{{- $common := (resources.Match "css/common/*.css") | resources.Concat "assets/css/common.css" }}
{{- $commonHighlight := (resources.Get "css/common/highlight.scss") | resources.ToCSS }}
{{- /* order is important */}}
{{- $core := (slice $theme_vars $reset $common $commonHighlight $media) | resources.Concat "assets/css/core.css" }}
{{- $extended := (resources.Match "css/extended/*.css") | resources.Concat "assets/css/extended.css" }}
{{- $extendedScss := (resources.Match "css/extended/*.scss") | resources.Concat "assets/css/extended.scss" | resources.ToCSS }}
{{- /* bundle all required css */}}
{{- /* Add extended css after theme style */ -}}
{{- $stylesheet := (slice $core $extended $extendedScss) | resources.Concat "assets/css/stylesheet.css" | minify }}
{{- if not site.Params.assets.disableFingerprinting }}
{{- $stylesheet := $stylesheet | fingerprint }}
<link crossorigin="anonymous" href="{{ $stylesheet.RelPermalink }}" integrity="{{ $stylesheet.Data.Integrity }}" rel="preload stylesheet" as="style">
{{- else }}
<link crossorigin="anonymous" href="{{ $stylesheet.RelPermalink }}" rel="preload stylesheet" as="style">
{{- end }}
{{- /* Favicons */}}
<link rel="icon" href="{{ site.Params.favicon | default "favicon.ico" | absURL }}">
<link rel="apple-touch-icon" href="{{ site.Params.appleTouchIcon | default "apple-touch-icon.png" | absURL }}">
{{- /* RSS */}}
{{ range .AlternativeOutputFormats -}}
<link rel="{{ .Rel }}" type="{{ .MediaType.Type | html }}" href="{{ .Permalink | safeURL }}">
{{ end -}}
{{- range .AllTranslations -}}
<link rel="alternate" hreflang="{{ .Lang }}" href="{{ .Permalink }}">
{{ end -}}
{{- /* Misc */}}
{{- if hugo.IsProduction | or (eq site.Params.env "production") }}
{{- if site.GoogleAnalytics }}
{{- template "_internal/google_analytics.html" . }}
{{- end -}}
{{- if site.Params.useCustomAnalytics }}
{{- partialCached "custom_analytics.html" . "custom_analytics.html" }}
{{- end -}}
{{- end -}}
{{- /* https://developer.twitter.com/en/docs/twitter-for-websites/cards/guides/getting-started */}}
{{- if .Params.cover.image }}
<meta name="twitter:card" content="summary_large_image" />
{{- else }}
{{- with site.Params.images -}}
<meta name="twitter:card" content="summary" />
{{- end }}
{{- end }}
<meta name="twitter:title" content="{{ $pageTitle }}" />
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}" />
{{- with site.Params.socialAccounts.twitter }}
<meta name="twitter:site" content="@{{ .username }}" />
<meta name="twitter:creator" content="@{{ .username }}" />
{{- end }}
{{- template "partials/templates/opengraph.html" (dict "page" . "pageTitle" $pageTitle) }}
{{- template "partials/templates/schema_json.html" (dict "page" . "pageTitle" $pageTitle) }}
{{- partial "extend_head.html" . }}
<noscript>
<style>
#theme-toggle,
.top-link {
display: none;
}
</style>
{{- if (and (ne site.Params.defaultTheme "light") (ne site.Params.defaultTheme "dark")) }}
<style>
@media (prefers-color-scheme: dark) {
:root {
--theme: rgb(29, 30, 32);
--entry: rgb(46, 46, 51);
--primary: rgb(218, 218, 219);
--secondary: rgb(155, 156, 157);
--tertiary-bg: rgb(65, 66, 68);
--content: rgb(196, 196, 197);
--code-bg: rgb(55, 56, 62);
--border: rgb(51, 51, 51);
}
.list-page {
background: var(--theme);
}
.list-page:not(.dark)::-webkit-scrollbar-track {
background: 0 0;
}
.list-page:not(.dark)::-webkit-scrollbar-thumb {
border-color: var(--theme);
}
}
</style>
{{- end }}
</noscript>