From a461f6d44f994b963ffe60dec2ac4646d9029109 Mon Sep 17 00:00:00 2001 From: Reorx Date: Fri, 9 Sep 2022 11:30:49 +0800 Subject: [PATCH] add essays section layout --- assets/css/common/post-single.css | 4 +- assets/css/core/theme-vars.css | 4 ++ assets/css/extended/essays.scss | 35 ++++++++++++++++ layouts/essays/section.html | 70 +++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 assets/css/extended/essays.scss create mode 100644 layouts/essays/section.html diff --git a/assets/css/common/post-single.css b/assets/css/common/post-single.css index 7095192..644eaed 100644 --- a/assets/css/common/post-single.css +++ b/assets/css/common/post-single.css @@ -12,7 +12,7 @@ color: var(--secondary); opacity: .8; padding-left: .5em; - border-left: 3px solid var(--tertiary); + border-left: 8px solid var(--signature); } .post-meta, @@ -141,7 +141,7 @@ h6:hover .anchor { } .post-content li { - margin-top: 10px; + margin-top: .5em; } .post-content li p { diff --git a/assets/css/core/theme-vars.css b/assets/css/core/theme-vars.css index d67a361..5b2c7f8 100644 --- a/assets/css/core/theme-vars.css +++ b/assets/css/core/theme-vars.css @@ -26,6 +26,10 @@ --link-hover-underline-shadow: 0 2px 0 var(--link-hover-underline-color); --link-transition: all 0.3s ease; --line-yellow: url("data:image/svg+xml;charset=utf-8,%3Csvg preserveAspectRatio='none' width='120' height='6' viewBox='0 0 120 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M119 0.8C60 4 50-0.5 1 1.5' stroke='%23fc0' stroke-width='3' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); + + /* for type pages theming */ + --signature: var(--primary); + --signature-bg: var(--secondary); } @media screen and (max-width: 500px) { :root { diff --git a/assets/css/extended/essays.scss b/assets/css/extended/essays.scss new file mode 100644 index 0000000..0881a4a --- /dev/null +++ b/assets/css/extended/essays.scss @@ -0,0 +1,35 @@ +/* +color candidates: +#48C0A3 青碧 +#519A73 蒼黃 +#1BD1A5 碧色 +#7BCFA6 玉色 +*/ +body.type-essays { + --signature: #48C0A3; + --signature-bg: rgba(72, 192, 164, 0.427); + // override theme-vars + --link-hover-color: var(--signature); + --link-hover-underline-color: var(--signature); + --link-hover-underline-shadow: 0 2px 0 var(--link-hover-underline-color); + + .post-entry { + /* same as .post-header h2 */ + .entry-title { + font-size: 24px; + line-height: 1.3; + margin-bottom: calc(var(--content-gap) / 2); + a { + color: var(--primary); + transition: var(--link-transition); + &:hover { + color: var(--link-hover-color); + box-shadow: var(--link-hover-underline-shadow); + } + } + } + .post-meta { + margin-bottom: var(--content-gap); + } + } +} diff --git a/layouts/essays/section.html b/layouts/essays/section.html new file mode 100644 index 0000000..95b06e5 --- /dev/null +++ b/layouts/essays/section.html @@ -0,0 +1,70 @@ +{{- define "main" }} + + + +{{- if .Content }} +
+ {{- if not (.Param "disableAnchoredHeadings") }} + {{- partial "anchored_headings.html" .Content -}} + {{- else }}{{ .Content }}{{ end }} +
+{{- end }} + + +{{- $pages := .Pages }} +{{- $pages = where $pages "Params.hidden" "!=" true }} + +{{/* related issue: https://github.com/gohugoio/hugo/issues/9003 */}} +{{ $paginator := "" }} +{{ if (.Param "paginate") }} + {{- $paginator = .Paginate $pages (.Param "paginate") }} +{{ else }} + {{- $paginator = .Paginate $pages }} +{{ end }} + +{{- $term := .Data.Term }} +{{- range $index, $page := $paginator.Pages }} + +
+

+ + {{- .Title }} + {{- if .Draft }}  [Draft]{{- end }} + {{- if .Weight }}  [Pinned]{{- end }} + +

+ +
+ {{ .Content }} +
+
+{{- end }} + +{{- if gt $paginator.TotalPages 1 }} + +{{- end }} + +{{- end }}{{- /* end main */ -}}