diff options
| author | Eltrac <hi@guhub.cn> | 2024-12-19 14:41:26 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2024-12-19 14:41:26 +0800 |
| commit | 103be55e7daec04b8da85ee175a9ec2317a167b0 (patch) | |
| tree | 99af7983332c60d0f276416a34d936a5581fede8 /layouts | |
| parent | c695b9511ba695bc57144b8c3f72e08625cce29a (diff) | |
refactor: disable theme and move layout files to root
Diffstat (limited to 'layouts')
| -rw-r--r-- | layouts/404.html | 7 | ||||
| -rw-r--r-- | layouts/_default/list.html | 25 | ||||
| -rw-r--r-- | layouts/_default/single.html | 65 | ||||
| -rw-r--r-- | layouts/index.calheatmap.json | 15 | ||||
| -rw-r--r-- | layouts/index.html | 62 | ||||
| -rw-r--r-- | layouts/partials/footer.html | 10 | ||||
| -rw-r--r-- | layouts/partials/head.html | 17 | ||||
| -rw-r--r-- | layouts/partials/head/css.html | 17 | ||||
| -rw-r--r-- | layouts/partials/head/headscript.html | 24 | ||||
| -rw-r--r-- | layouts/partials/head/siteinfo.html | 66 | ||||
| -rw-r--r-- | layouts/partials/header.html | 17 | ||||
| -rw-r--r-- | layouts/partials/scripts.html | 31 | ||||
| -rw-r--r-- | layouts/partials/snippets/document-end.html | 9 | ||||
| -rw-r--r-- | layouts/partials/snippets/document-start.html | 5 | ||||
| -rw-r--r-- | layouts/shortcodes/bloglink.html | 11 | ||||
| -rw-r--r-- | layouts/shortcodes/book.html | 17 | ||||
| -rw-r--r-- | layouts/shortcodes/callout.html | 6 | ||||
| -rw-r--r-- | layouts/shortcodes/gallery.html | 3 | ||||
| -rw-r--r-- | layouts/shortcodes/img.html | 20 | ||||
| -rw-r--r-- | layouts/shortcodes/quotecard.html | 3 |
20 files changed, 430 insertions, 0 deletions
diff --git a/layouts/404.html b/layouts/404.html new file mode 100644 index 00000000..b58ec77b --- /dev/null +++ b/layouts/404.html @@ -0,0 +1,7 @@ +{{ define "main"}} + <main id="main"> + <div> + <h1 id="title"><a href="{{ "/" | relURL }}">Go Home</a></h1> + </div> + </main> +{{ end }}
\ No newline at end of file diff --git a/layouts/_default/list.html b/layouts/_default/list.html new file mode 100644 index 00000000..8cc70a0d --- /dev/null +++ b/layouts/_default/list.html @@ -0,0 +1,25 @@ +{{ partial "snippets/document-start.html" . }} + <article class="posts"> + {{ partial "header.html" . }} + <h1 class="taxonomy-term">{{.Data.Term}}</h1> + <div id="posts-list"> + {{ range .Pages }} + <div class="row posts-line"> + <div class="posts-date col-xs-2"> + <time datetime="{{ .Date.Format "2006-01-02 15:04:05 MST" }}">{{ .Date.Format "06/01/02"}}</time> + </div> + <div class="posts-title col-xs-10"> + <div class="row"> + <div class="col-xs-12"> + <a href="{{ .RelPermalink }}" data-umami-event="Click Post Link from Category Page"> + {{ .Title }}{{ with .Params.subtitle }}:<span class="posts-subtitle">{{. }}</span> + {{ end }} + </a> + </div> + </div> + </div> + </div> + {{ end }} + </div> + </article> +{{ partial "snippets/document-end.html" . }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html new file mode 100644 index 00000000..a1b0b111 --- /dev/null +++ b/layouts/_default/single.html @@ -0,0 +1,65 @@ +{{ partial "snippets/document-start.html" . }} + <article class="post {{ .Site.Language.LanguageName }}" id="article"> + + <!-- Site Header --> + <div class="site-header"> + {{ partial "header.html" . }} + </div> + <!-- Post Header --> + <header class="post-header"> + {{ if in .Site.Params.mainSections .Type }} + <!-- Title and Subtitle --> + <h1 class="post-title"> + {{ .Title }} + {{ with .Params.subtitle }} + <small class="post-subtitle">{{ . }}</small> + {{ end }} + </h1> + <!-- Post Meta --> + <div class="row post-desc"> + <div class="col-xs-6"> + {{ if .Date }} + <time class="post-date" datetime="{{ .Date.Format "2006-01-02 15:04:05 MST" }}"> + {{ .Date.Format "02 Jan 2006" }} + </time> + {{ end }} + <span> / </span> + <span><span class="waline-pageview-count">…</span> Views</span> + </div> + </div> + {{ end }} + </header> + + <!-- Post Content --> + <div id="post-content" class="post-content markdown-body"> + {{ .Site.Params.postHeaderContent | safeHTML }} + {{ .Content }} + </div> + + <!-- Post Tags --> + <!-- <div class="row middle-xs"> + <div class="col-xs-12"> + {{ range .Params.tags }} + <div class="post-tags"> + <a href="{{ site.LanguagePrefix }}/tags/{{ lower . | urlize }}/"> + {{ . }} + </a> + </div> + {{ end }} + </div> + </div> --> + + <!-- Post Comments --> + {{ if in .Site.Params.mainSections .Type }} + <!-- waline --> + <div style="height: 50px;"></div> + <div class="post-comments"> + <div id="waline"></div> + </div> + {{ end }} + + </article> + <!-- use fancybox --> + <!-- the reason it is replace here it that the fancybox.js is loaded after the swup.js --> + <script>Fancybox.bind("[data-fancybox]");</script> +{{ partial "snippets/document-end.html" . }} diff --git a/layouts/index.calheatmap.json b/layouts/index.calheatmap.json new file mode 100644 index 00000000..65b1d942 --- /dev/null +++ b/layouts/index.calheatmap.json @@ -0,0 +1,15 @@ +{{- /* 设置 Content-Type 为 JSON */ -}} +{{- $entries := slice -}} +{{- range .Site.RegularPages -}} + {{- $wordCount := .WordCount -}} + {{- $date := .Date.Format "2006-01-02" -}} + {{- $entry := dict "date" $date "value" $wordCount -}} + {{- $entries = $entries | append $entry -}} +{{- end -}} +{{- $.Scratch.Add "results" $entries -}} +[ + {{- range $i, $entry := $.Scratch.Get "results" -}} + {{- if $i }},{{ end -}} + {{- $entry | jsonify -}} + {{- end -}} +] diff --git a/layouts/index.html b/layouts/index.html new file mode 100644 index 00000000..8ded46d5 --- /dev/null +++ b/layouts/index.html @@ -0,0 +1,62 @@ +{{ partial "snippets/document-start.html" . }} + <article class="posts"> + {{ partial "header.html" . }} + <div id="posts-list"> + {{ $currentYear := now.Format "2006" }} <!-- 获取当前年份 --> + + {{ $isFirstPost := true }} <!-- 用于标记首页的第一篇文章 --> + + {{ range (where site.RegularPages "Type" "in" site.Params.mainSections).GroupByDate "2006" -}} + <section class="posts-year-section"> + <h1 class="site-date-catalog posts-year-title">{{ .Key }}</h1> + + {{ range .Pages.GroupByDate "01" }} + <h2>{{ .Key }} 月</h2> + <ul> + {{ range .Pages }} + <li class="{{ if $isFirstPost }}first-post{{ end }}"> + <!-- 首页第一篇文章特殊展示 --> + <div class="row posts-line {{ if $isFirstPost }}featured-post{{ end }}"> + <div class="posts-date col-xs-3 col-sm-2"> + <time datetime="{{ .Date.Format "2006-01-02 15:04:05 MST" }}">{{ .Date.Format "Jan 02" }}</time> + </div> + <div class="posts-title col-xs-9 col-sm-10"> + <div class="row"> + <div class="col-xs-11 col-sm-10"> + <a + class="posts-title-link" + href="{{ .RelPermalink }}" + data-umami-event="Click Post Link from Index" + >{{ .Title }}</a> + <div class="posts-excerpt markdown-body"> + {{ if $isFirstPost }} + {{ if .Params.description }} + <p>{{.Params.description }}</p> + {{ else }} + <p>{{ .Summary }}</p> + {{ end }} + {{ $isFirstPost = false }} + {{ end }} + </div> + </div> + <div class="col-xs-1 col-sm-2 posts-categories"> + {{ with .Params.categories }} + <div class="posts-category"> + <a href="/categories/{{ . }}/"><strong>{{ . }}</strong></a> + </div> + {{ end }} + </div> + </div> + </div> + </div> + </li> + {{ end }} + </ul> + {{ end }} + + </section> + <hr> + {{ end }} + </div> + </article> +{{ partial "snippets/document-end.html" . }} diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html new file mode 100644 index 00000000..7a7c264c --- /dev/null +++ b/layouts/partials/footer.html @@ -0,0 +1,10 @@ +<div class="site-footer"> + <!-- 全站字数统计--> + {{$scratch := newScratch}} + {{ range (where .Site.Pages "Kind" "page" )}} + {{$scratch.Add "total" .WordCount}} + {{ end }} + <div class="site-footer-item">🪦 {{$scratch.Get "total" }} 字在这里<span style="display:inline-block; transform:rotate(7deg) translateY(0.15rem); filter: blur(1px)">死去</span></div> + + <p style="text-align: center;">You've reached the end.</p> +</div>
\ No newline at end of file diff --git a/layouts/partials/head.html b/layouts/partials/head.html new file mode 100644 index 00000000..8ae6c46f --- /dev/null +++ b/layouts/partials/head.html @@ -0,0 +1,17 @@ +<head> + <meta charset="utf-8" /> + {{ hugo.Generator }} + + <meta http-equiv="X-UA-Compatible" content="IE=edge" /> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + <meta name="author" content="{{ .Site.Author.name }}" /> + <meta property="og:url" content="{{ .Permalink }}" /> + <link rel="canonical" href="{{ .Permalink }}" /> + + {{ partial "head/siteinfo" . }} + {{ partial "head/css" . }} + {{ partial "head/headscript" . }} + + <!-- Extra head --> + {{ .Site.Params.extraHead | safeHTML }} +</head> diff --git a/layouts/partials/head/css.html b/layouts/partials/head/css.html new file mode 100644 index 00000000..b2193666 --- /dev/null +++ b/layouts/partials/head/css.html @@ -0,0 +1,17 @@ +<!-- theme css --> +{{ with resources.Get "css/index.css" | minify }} +<style>{{ .Content | safeCSS }}</style> +{{ end }} +{{ with resources.Get "css/flexboxgrid-6.3.1.min.css" | minify }} +<style>{{ .Content | safeCSS }}</style> +{{ end }} + +<!-- Google Fonts --> +<link rel="preconnect" href="https://fonts.googleapis.com"> +<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> +<link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@200..900&display=swap" rel="stylesheet"> + +<!-- Extra --> +{{ range .Site.Params.extraCSSFiles -}} +<link rel="stylesheet" href="{{ $.Site.Params.staticPrefix }}{{ . | relURL }}"> +{{- end }} diff --git a/layouts/partials/head/headscript.html b/layouts/partials/head/headscript.html new file mode 100644 index 00000000..8ed6fd40 --- /dev/null +++ b/layouts/partials/head/headscript.html @@ -0,0 +1,24 @@ +<!-- Global JavaScript Variables --> +<script> + var waline_options = { + // basic configuration + el: '#waline', + serverURL: 'https://waline.geedea.pro', + dark: 'auto', + search: false, + // if localhost then disable pageview count + pageview: (location.href.includes('localhost')) ? false : true + }; +</script> + +<script> +/* === umami tracking === */ +if (window.location.hostname !== 'localhost') { + // track traffic + const script = document.createElement('script'); + script.defer = true; + script.src = 'https://cloud.umami.is/script.js'; + script.dataset.websiteId = 'ae8c2619-56eb-4577-ac31-9dc6ea44bda7'; + document.head.appendChild(script); +} +</script> diff --git a/layouts/partials/head/siteinfo.html b/layouts/partials/head/siteinfo.html new file mode 100644 index 00000000..c5c355e8 --- /dev/null +++ b/layouts/partials/head/siteinfo.html @@ -0,0 +1,66 @@ +<!-- Basic site information --> +{{- if .IsHome -}} +<title>{{ .Site.Title }}</title> +<meta property="og:title" content="{{ .Site.Title }}" /> +<meta property="og:type" content="website" /> +<meta property="og:description" content="{{ .Site.Params.description }}" /> +<meta name="description" content="{{ .Site.Params.description }}" /> +{{- else -}} +<title>{{ .Title }}</title> +<meta property="og:title" content="{{ .Title }}" /> +<meta property="og:type" content="article" /> +<meta property="og:description" content="{{ default .Summary .Description | plainify }}" /> +<meta name="description" content="{{ default .Summary .Description | plainify }}" /> +{{- end }} +<meta property="og:locale" content="{{ .Site.LanguageCode }}" /> +{{- if .Params.album -}} +<meta property="og:image" content="{{ .Params.album }}" /> +{{- else -}} +<meta property="og:image" content="{{ .Site.Params.favicon }}" /> +{{ end }} + +<!-- Favicon --> +{{- if .Site.Params.favicon -}} +<link rel="apple-touch-icon" href="{{ .Site.Params.favicon }}" /> +<link rel="icon" href="{{ .Site.Params.favicon }}" /> +<link rel="shortcut" href="{{ .Site.Params.favicon }}" /> +{{- end -}} + +<!-- RSS --> +<link rel="alternate" type="application/atom+xml" href="{{.Site.BaseURL}}index.xml" title="{{ .Site.Title }}"> +<link href="{{ .Site.Params.staticPrefix }}{{ "index.xml" | relURL }}" rel="alternate" type="application/rss+xml" + title="{{ .Site.Title }}"> + +<!-- Twtter Card --> +{{ if .Site.Params.TwitterCards }}{{ template "_internal/twitter_cards.html" . }}{{ end }} + +<!-- JSON-LD --> +<script type="application/ld+json"> + { + "@context" : "http://schema.org", + "@type" : "BlogPosting", + "mainEntityOfPage": { + "@type": "WebPage", + "@id": "{{ .Site.BaseURL }}" + }, + "articleSection" : "{{ .Section }}", + "name" : "{{ .Title }}", + "headline" : "{{ .Title }}", + {{ if .IsHome -}} + "description" : "{{ .Site.Params.description | plainify }}", + {{- else -}} + "description" : "{{ default .Summary .Description | plainify }}", + {{- end }} + "inLanguage" : "zh-CN", + "author" : "{{ .Site.Author.name }}", + "creator" : "{{ .Site.Author.name }}", + "publisher": "{{ .Site.Author.name }}", + "accountablePerson" : "{{ .Site.Author.name }}", + "copyrightHolder" : "{{ .Site.Author.name }}", + "copyrightYear" : "{{ .Date.Format "2006" }}", + "datePublished": "{{ .Date }}", + "dateModified" : "{{ .Date }}", + "url" : "{{ .Permalink }}", + "keywords" : [ {{ if isset .Params "tags" }}{{ range .Params.tags }}"{{ . }}",{{ end }}{{ end }} ] + } +</script> diff --git a/layouts/partials/header.html b/layouts/partials/header.html new file mode 100644 index 00000000..b1f6e50e --- /dev/null +++ b/layouts/partials/header.html @@ -0,0 +1,17 @@ +<!-- Header Title --> +<header> + <div class="header-title"> + <a href="{{ .Site.LanguagePrefix }}/" + >{{ or .Site.Params.headTitle .Site.Author.name }}</a + > + </div> +</header> + +<!-- Navigation --> +<nav class="header-items"> + {{ range .Site.Params.nav }} + <div class="header-item {{ if eq .link $.Page.RelPermalink }}active{{ end }}"> + <a href="{{ .link }}" target="{{ .target }}">{{ .name }}</a> + </div> + {{ end }} +</nav> diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html new file mode 100644 index 00000000..a2cbb997 --- /dev/null +++ b/layouts/partials/scripts.html @@ -0,0 +1,31 @@ +<!-- third-party libraries --> +<script src="https://unpkg.com/swup@4"></script> +<script src="https://unpkg.com/@fancyapps/ui@5.0.36/dist/fancybox/fancybox.umd.js"></script> +<script type="module"> +import { init } from 'https://unpkg.com/@waline/client@v3/dist/waline.js'; + +/* === waline === */ + +function loadWalineComment() { + // terminate if no waline container is found + const container = document.getElementById("waline"); + if (!container) return; + + // initialize waline + const path_suffix = window.location.pathname.endsWith('/') ? '' : '/'; + waline_options.path = window.location.pathname + path_suffix; + try { + init(waline_options); + } catch (error) { console.log(error) } + + // track waline button events + const walineButton = document.querySelector("#waline > div > div.wl-comment > div > div.wl-footer > div.wl-info > button.primary.wl-btn"); + walineButton.addEventListener("click", () => umami.track("Comment")); +} + +loadWalineComment(); + +/* === swup === */ +const swup = new Swup(); +swup.hooks.on('page:view', loadWalineComment); +</script> diff --git a/layouts/partials/snippets/document-end.html b/layouts/partials/snippets/document-end.html new file mode 100644 index 00000000..2fc27a07 --- /dev/null +++ b/layouts/partials/snippets/document-end.html @@ -0,0 +1,9 @@ + <!-- Footer --> + {{ partial "footer.html" . }} + </main> + {{ partial "scripts.html" . }} + {{ if .Site.Params.extraBody }} + {{ .Site.Params.extraBody | safeHTML }} + {{ end }} + </body> +</html>
\ No newline at end of file diff --git a/layouts/partials/snippets/document-start.html b/layouts/partials/snippets/document-start.html new file mode 100644 index 00000000..56b12280 --- /dev/null +++ b/layouts/partials/snippets/document-start.html @@ -0,0 +1,5 @@ +<!DOCTYPE html> +<html lang="{{ .Site.LanguageCode }}" prefix="og: http://ogp.me/ns#"> +{{ partial "head.html" . }} +<body> + <main id="swup" class="transition-fade">
\ No newline at end of file diff --git a/layouts/shortcodes/bloglink.html b/layouts/shortcodes/bloglink.html new file mode 100644 index 00000000..4cdec219 --- /dev/null +++ b/layouts/shortcodes/bloglink.html @@ -0,0 +1,11 @@ +<a href="{{.Get "link" }}" class="blog-link" target="_blank"> + {{ if and (isset .Params "image") .Params.image }} + <div class="blog-link-image"> + <img src="{{ .Params.image }}" alt="{{ .Params.title }}" /> + </div> + {{ end }} + <div class="blog-link-content"> + <h4>{{.Get "title" }}</h4> + <p>{{.Get "description" }}</p> + </div> +</a>
\ No newline at end of file diff --git a/layouts/shortcodes/book.html b/layouts/shortcodes/book.html new file mode 100644 index 00000000..17747acc --- /dev/null +++ b/layouts/shortcodes/book.html @@ -0,0 +1,17 @@ +<div class="book-showcase"> + <div class="book-cover"> + <a href="{{ .Get "cover" }}" data-fancybox> + <img src="{{ .Get "cover" }}" /> + </a> + </div> + <div class="book-description"> + <div class="book-description-header"> + <h3 class="book-title">{{ .Get "title" }}</h3> + <p>分数:{{ .Get "rating" }}</p> + </div> + <div> + + {{ .Inner | markdownify }} + </div> + </div> +</div> diff --git a/layouts/shortcodes/callout.html b/layouts/shortcodes/callout.html new file mode 100644 index 00000000..62112390 --- /dev/null +++ b/layouts/shortcodes/callout.html @@ -0,0 +1,6 @@ +<div class="callout"> + <div class="callout-icon">{{ index .Params 1 }}</div> + <div class="callout-text"> + {{ index .Params 0 | markdownify }} + </div> +</div>
\ No newline at end of file diff --git a/layouts/shortcodes/gallery.html b/layouts/shortcodes/gallery.html new file mode 100644 index 00000000..a6e4d1b5 --- /dev/null +++ b/layouts/shortcodes/gallery.html @@ -0,0 +1,3 @@ +<div class="inline-image"> + {{ .Inner | safeHTML }} +</div> diff --git a/layouts/shortcodes/img.html b/layouts/shortcodes/img.html new file mode 100644 index 00000000..4fd1f739 --- /dev/null +++ b/layouts/shortcodes/img.html @@ -0,0 +1,20 @@ +<!-- image --> +<figure {{ with .Get "class" }}class="{{ . }}"{{ end }}> +{{ with .Get "link" }}<a href="{{ . }}">{{ end }} + <a href="{{ .Get "src" }}" data-fancybox {{ if isset .Params "title" }} data-caption="{{.Get "title" }}" {{ end }}> + <img src="{{ .Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" }}{{ end }}"{{ end }} /> + </a> + {{ if .Get "link" }}</a>{{ end }} + {{ if or (or (.Get "title") (.Get "caption")) (.Get "attr") }} + <figcaption>{{ if isset .Params "title" }} + <h4>{{ .Get "title" }}</h4>{{ end }} + {{ if or (.Get "caption") (.Get "attr") }}<p> + {{ .Get "caption" }} + {{ with .Get "attrlink" }}<a href="{{ . }}"> {{ end }} + {{ .Get "attr" }} + {{ if .Get "attrlink" }}</a> {{ end }} + </p> {{ end }} + </figcaption> +{{ end }} +</figure> +<!-- image -->
\ No newline at end of file diff --git a/layouts/shortcodes/quotecard.html b/layouts/shortcodes/quotecard.html new file mode 100644 index 00000000..dfaf04e2 --- /dev/null +++ b/layouts/shortcodes/quotecard.html @@ -0,0 +1,3 @@ +<div class="quote-card" {{ with .Get "rotate" }}style="transform: rotate({{. }}deg)"{{ end }}> + {{ .Inner | markdownify }} +</div>
\ No newline at end of file |
