wip(js): add head.html and assets/js
This commit is contained in:
104
layouts/partials/head.html
Normal file
104
layouts/partials/head.html
Normal file
@ -0,0 +1,104 @@
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#f7f7f7">
|
||||
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#1b1b1e">
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, user-scalable=no initial-scale=1, shrink-to-fit=no, viewport-fit=cover"
|
||||
>
|
||||
|
||||
{{ template "_internal/opengraph.html" }}
|
||||
{{ template "_internal/twitter_cards.html" }}
|
||||
{{ template "_internal/schema.html" }}
|
||||
|
||||
<!-- Setup Open Graph image -->
|
||||
{{ if .Params.image }}
|
||||
{{ $src := .Params.image }}
|
||||
{{ $imgUrl := "" }}
|
||||
|
||||
{{ if not (findRE "://" $src) }}
|
||||
{{ $imgUrl = absURL $src }}
|
||||
{{ $oldUrl := $src | absURL }}
|
||||
{{ $newUrl := $imgUrl }}
|
||||
<!-- Hugo doesn't have direct string replacement in templates,
|
||||
so we'd need to handle this differently or use a custom function -->
|
||||
{{ end }}
|
||||
{{ else if site.Params.social_preview_image }}
|
||||
{{ $imgUrl := site.Params.social_preview_image | absURL }}
|
||||
<meta property="og:image" content="{{ $imgUrl }}" />
|
||||
<meta name="twitter:card" content="summary_large_image" />
|
||||
<meta property="twitter:image" content="{{ $imgUrl }}" />
|
||||
{{ end }}
|
||||
|
||||
<title>
|
||||
{{ if ne .Kind "home" }}
|
||||
{{ .Title | safeHTML }} |
|
||||
{{ end }}
|
||||
{{ site.Title }}
|
||||
</title>
|
||||
|
||||
{{ partial "favicons.html" . }}
|
||||
|
||||
<!-- Resource Hints -->
|
||||
{{ if not site.Params.assets.self_host.enabled }}
|
||||
{{ range site.Data.origin.cors.resource_hints }}
|
||||
{{ range .links }}
|
||||
<link rel="{{ .rel }}" href="{{ .url }}" {{ delimit .opts " " | safeHTMLAttr }}>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
<!-- Bootstrap -->
|
||||
{{ if not hugo.IsProduction }}
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
|
||||
{{ end }}
|
||||
|
||||
<!-- Theme style -->
|
||||
<link rel="stylesheet" href="{{ (printf "/assets/css/%s.css" site.Params.theme) | relURL }}">
|
||||
|
||||
<!-- Web Font -->
|
||||
<link rel="stylesheet" href="{{ site.Data.origin.webfonts | relURL }}">
|
||||
|
||||
<!-- Font Awesome Icons -->
|
||||
<link rel="stylesheet" href="{{ site.Data.origin.fontawesome.css | relURL }}">
|
||||
|
||||
<!-- 3rd-party Dependencies -->
|
||||
{{ if and site.Params.toc .Params.toc }}
|
||||
<link rel="stylesheet" href="{{ site.Data.origin.toc.css | relURL }}">
|
||||
{{ end }}
|
||||
|
||||
{{ if or (eq .Type "post") (eq .Type "page") (eq .Kind "home") }}
|
||||
<link rel="stylesheet" href="{{ site.Data.origin.lazy_polyfill.css | relURL }}">
|
||||
{{ end }}
|
||||
|
||||
{{ if or (eq .Type "page") (eq .Type "post") }}
|
||||
<!-- Image Popup -->
|
||||
<link rel="stylesheet" href="{{ site.Data.origin.glightbox.css | relURL }}">
|
||||
{{ end }}
|
||||
|
||||
<!-- Scripts -->
|
||||
<script src="{{ "/assets/js/dist/theme.min.js" | relURL }}"></script>
|
||||
|
||||
{{ partial "js-selector.html" . }}
|
||||
|
||||
{{ if hugo.IsProduction }}
|
||||
<!-- PWA -->
|
||||
{{ if site.Params.pwa.enabled }}
|
||||
<script
|
||||
defer
|
||||
src="{{ "/app.min.js" | relURL }}?baseurl={{ site.BaseURL }}®ister={{ site.Params.pwa.cache.enabled }}"
|
||||
></script>
|
||||
{{ end }}
|
||||
|
||||
<!-- Web Analytics -->
|
||||
{{ range $platform, $config := site.Params.analytics }}
|
||||
{{ if and $config.id (ne $config.id "") }}
|
||||
{{ partial (printf "analytics/%s.html" $platform) . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ partial "metadata-hook.html" . }}
|
||||
</head>
|
Reference in New Issue
Block a user