diff options
Diffstat (limited to 'layouts')
| -rw-r--r-- | layouts/_default/archives.html | 10 | ||||
| -rw-r--r-- | layouts/_default/baseof.html | 4 | ||||
| -rw-r--r-- | layouts/_default/list.html | 11 | ||||
| -rw-r--r-- | layouts/_default/rss.xml | 16 | ||||
| -rw-r--r-- | layouts/_default/single.html | 24 | ||||
| -rw-r--r-- | layouts/newsletter/archives.html | 33 | ||||
| -rw-r--r-- | layouts/newsletter/section.html | 50 | ||||
| -rw-r--r-- | layouts/partials/head.html | 9 | ||||
| -rw-r--r-- | layouts/partials/header.html | 2 | ||||
| -rw-r--r-- | layouts/partials/newsletter_brand.html | 8 | ||||
| -rw-r--r-- | layouts/partials/newsletter_sub_form.html | 8 | ||||
| -rw-r--r-- | layouts/partials/post_nav_links.html | 8 |
12 files changed, 160 insertions, 23 deletions
diff --git a/layouts/_default/archives.html b/layouts/_default/archives.html index 966da8a..dd53699 100644 --- a/layouts/_default/archives.html +++ b/layouts/_default/archives.html @@ -9,7 +9,13 @@ {{- end }} </header> -{{- $pages := where site.AllPages "Type" "in" site.Params.mainSections }} +{{/* get pages from the current page's section */}} +{{/* in this way, archives.html could be used for section archives other than the only one archives of the whole site */}} +{{- $sections := site.Params.mainSections }} +{{- if .Section }} + {{- $sections = slice .Section }} +{{- end }} +{{- $pages := where (where site.RegularPages "Section" "in" $sections) "Params.hidden" "!=" true }} {{- range $pages.GroupByPublishDate "2006" }} {{- if ne .Key "0001" }} @@ -22,7 +28,6 @@ <h3 class="archive-month-header">{{- .Key }}<sup class="archive-count"> {{ len .Pages }}</sup></h3> <div class="archive-posts"> {{- range .Pages }} - {{- if eq .Kind "page" }} <div class="archive-entry"> <h3 class="archive-entry-title"> {{- .Title | markdownify }} @@ -34,7 +39,6 @@ <a class="entry-link" aria-label="post link to {{ .Title | plainify }}" href="{{ .Permalink }}"></a> </div> {{- end }} - {{- end }} </div> </div> {{- end }} diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 513450b..1413f56 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -8,11 +8,11 @@ <body class=" {{- if (or (ne .Kind `page` ) (eq .Layout `archives`) (eq .Layout `search`)) -}} -{{- print "list" -}} +{{- print "list-page" -}} {{- end -}} {{- if eq site.Params.defaultTheme `dark` -}} {{- print " dark" }} -{{- end -}} +{{- end }} type-{{ .Type }} kind-{{ .Kind }} layout-{{ .Layout -}} " id="top"> {{- partialCached "header.html" . .Page -}} <main class="main {{- if (eq .Kind `page`) -}}{{- print " post" -}}{{- end -}}"> diff --git a/layouts/_default/list.html b/layouts/_default/list.html index e2c248c..654297b 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -13,6 +13,14 @@ {{ .Description | markdownify }} </div> {{- end }} + <div class="inline-links"> + {{- with .Param "archivesSlug" }} + <a href="{{ $.RelPermalink }}{{ . }}/">Archives</a> + {{- end }} + {{ with .OutputFormats.Get "rss" -}} + • <a href="{{ .Permalink }}" target="_blank">RSS</a> + {{ end -}} + </div> </header> {{- end }} @@ -27,7 +35,8 @@ {{- $pages := .Pages }} {{- if .IsHome }} - {{- $pages = where site.RegularPages "Type" "in" site.Params.mainSections }} + {{/* get all regular pages instead of pages in a section */}} + {{- $pages = where site.RegularPages "Section" "in" site.Params.mainSections }} {{- end }} {{- $pages = where $pages "Params.hidden" "!=" true }} diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml index 5a6386f..f151df5 100644 --- a/layouts/_default/rss.xml +++ b/layouts/_default/rss.xml @@ -1,15 +1,15 @@ -{{- $pctx := . -}} -{{- if .IsHome -}}{{ $pctx = site }}{{- end -}} -{{- $pages := slice -}} -{{- if or $.IsHome $.IsSection -}} -{{- $pages = where $pctx.RegularPages "Type" "in" site.Params.mainSections }} -{{- else -}} -{{- $pages = $pctx.Pages -}} -{{- end -}} +{{- $pages := .Pages -}} +{{- if $.IsHome -}} + {{/* get all regular pages instead of pages in a section */}} + {{- $pages = where site.RegularPages "Section" "in" site.Params.mainSections -}} +{{- end }} +{{- $pages = where $pages "Params.hidden" "!=" true -}} + {{- $limit := site.Config.Services.RSS.Limit -}} {{- if ge $limit 1 -}} {{- $pages = $pages | first $limit -}} {{- end -}} + {{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }} <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"> <channel> diff --git a/layouts/_default/single.html b/layouts/_default/single.html index c71f66d..fa4c86d 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,15 +1,24 @@ {{- define "main" }} +{{- $isNewsletter := eq .Type "newsletter" }} <article class="post-single"> <header class="post-header"> {{ partial "breadcrumbs.html" . }} + + {{- if $isNewsletter -}} + {{- partial "newsletter_brand.html" . }} + {{- end -}} <h1 class="post-title"> - {{ .Title }} - {{- if .Draft }}<sup><span class="entry-isdraft"> [draft]</span></sup>{{- end }} + {{- if $isNewsletter -}} + {{- replace .Title (.Param "titlePrefix") (.Param "titlePrefixReplace") -}} + {{- else -}} + {{- .Title -}} + {{- end -}} + {{- if .Draft -}}<sup><span class="entry-isdraft"> [draft]</span></sup>{{- end -}} </h1> {{- if .Description }} <div class="post-description"> - {{ .Description }} + {{- .Description -}} </div> {{- end }} {{- if not (.Param "hideMeta") }} @@ -43,6 +52,15 @@ {{- if (.Param "ShowPostNavLinks") }} {{- partial "post_nav_links.html" . }} {{- end }} + + {{- if $isNewsletter }} + <div class="newsletter-sub"> + <div class="notice"> + 感谢你能读到这里,如果觉得有趣的话,欢迎在下方输入邮箱进行订阅。 + </div> + {{- partial "newsletter_sub_form.html"}} + </div> + {{- end }} </footer> {{- if not (.Param "noComments") }} diff --git a/layouts/newsletter/archives.html b/layouts/newsletter/archives.html new file mode 100644 index 0000000..ae19b5a --- /dev/null +++ b/layouts/newsletter/archives.html @@ -0,0 +1,33 @@ +{{- define "main" }} +<div class="main-icon">@</div> + +<div class="content"> + <h1>{{ .Title }}</h1> + {{- partial "newsletter_sub_form.html"}} + + {{/* get pages from the current page's section */}} + {{- $sections := slice .Section }} + {{- $pages := where (where site.RegularPages "Section" "in" $sections) "Params.hidden" "!=" true }} + + {{/* TODO statistics */}} + <div class="list"> + {{- range $pages }} + <div class="item"> + <div class="date"> + {{- if not .Date.IsZero -}} + {{ .Date | time.Format (default "January 2, 2006" site.Params.DateFormat) }} + {{- end }} + </div> + <div class="title"> + <a href="{{ .Permalink }}">{{- .Title }} + {{- if .Draft }}<em>[Draft]</em>{{- end }} + {{- if .Weight }}<em>[Pinned]</em>{{- end }} + </a> + </div> + <div class="issueno">{{ with .Param "issueno" }}#{{ . }}{{ end }}</div> + </div> + {{- end }} + </div> + +</div> +{{ end }} diff --git a/layouts/newsletter/section.html b/layouts/newsletter/section.html new file mode 100644 index 0000000..04c3eed --- /dev/null +++ b/layouts/newsletter/section.html @@ -0,0 +1,50 @@ +{{/* section is AKA list */}} + +{{- define "main" }} +<div class="main-icon">@</div> + +<div class="content"> + <h1>{{ .Title }}</h1> + {{ with .Param "subtitle" }}<div class="subtitle">{{ . }}</div>{{ end }} + + <div class="first-entry"> + <section class="entry-content">{{ .Description | markdownify }}</section> + {{- partial "newsletter_sub_form.html"}} + </div> + + {{ $pages := where .Pages "Params.hidden" "!=" true }} + {{ if $pages }} + <h2>最新通讯</h2> + + <div class="list"> + {{- range first 5 $pages }} + <div class="item"> + <div class="date"> + {{- if not .Date.IsZero -}} + {{ .Date | time.Format (default "January 2, 2006" site.Params.DateFormat) }} + {{- end }} + </div> + <div class="title"> + <a href="{{ .Permalink }}">{{- .Title }} + {{- if .Draft }}<em>[Draft]</em>{{- end }} + {{- if .Weight }}<em>[Pinned]</em>{{- end }} + </a> + </div> + <div class="issueno">{{ with .Param "issueno" }}#{{ . }}{{ end }}</div> + </div> + {{- end }} + </div> + {{ end }} + + <h2>相关链接</h2> + <div class="inline-links"> + {{- with .Param "archivesSlug" }} + <a href="{{ $.RelPermalink }}{{ . }}/">Archives</a> + {{- end }} + {{ with .OutputFormats.Get "rss" -}} + • <a href="{{ .Permalink }}" target="_blank">RSS</a> + {{ end -}} + </div> + +</div> +{{ end }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 1889a85..165afb4 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -47,10 +47,11 @@ {{- /* 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) | resources.Concat "assets/css/stylesheet.css" | minify }} +{{- $stylesheet := (slice $core $extended $extendedScss) | resources.Concat "assets/css/stylesheet.css" | minify }} {{- if not site.Params.assets.disableFingerprinting }} {{- $stylesheet := $stylesheet | fingerprint }} @@ -125,15 +126,15 @@ --border: rgb(51, 51, 51); } - .list { + .list-page { background: var(--theme); } - .list:not(.dark)::-webkit-scrollbar-track { + .list-page:not(.dark)::-webkit-scrollbar-track { background: 0 0; } - .list:not(.dark)::-webkit-scrollbar-thumb { + .list-page:not(.dark)::-webkit-scrollbar-thumb { border-color: var(--theme); } } diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 1061d5b..01f2b41 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -133,7 +133,7 @@ function toggleThemeListener() { <a href="{{ $menu_item_url }}" title="{{ .Title | default .Name }} {{- cond $is_search (" (Alt + /)" | safeHTMLAttr) ("" | safeHTMLAttr ) }}" {{- if $is_search -}}data-no-instant{{- end -}} {{- cond $is_search (" accesskey=/" | safeHTMLAttr) ("" | safeHTMLAttr ) }} - {{- if eq $menu_item_url $page_url }} class="active" {{- end }} + {{- if strings.HasPrefix $page_url $menu_item_url }} class="active" {{- end }} {{- if .Params.External }} target="_blank" {{- end }} > {{- .Pre }} diff --git a/layouts/partials/newsletter_brand.html b/layouts/partials/newsletter_brand.html new file mode 100644 index 0000000..03c10ee --- /dev/null +++ b/layouts/partials/newsletter_brand.html @@ -0,0 +1,8 @@ +<a class="newsletter-brand" href="{{ .Parent.Permalink }}"> + <div class="icon">@</div> + <div class="name">{{ .Param "newsletterName" }}</div> + {{ with .Param "issueno" }}<div class="remark">#{{ . }}</div>{{ end }} + <div class="arrow"> + <svg xmlns="http://www.w3.org/2000/svg" width="34" height="34" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg> + </div> +</a> diff --git a/layouts/partials/newsletter_sub_form.html b/layouts/partials/newsletter_sub_form.html new file mode 100644 index 0000000..3cee447 --- /dev/null +++ b/layouts/partials/newsletter_sub_form.html @@ -0,0 +1,8 @@ +{{/* Add `layouts/partials/newsletter_sub_form.html` in your own code to customize the form */}} + +<div class="sub-form"> + <form action=""> + <input type="text" name="email" placeholder="Your email address"> + <button>订阅 | Subscribe</button> + </form> +</div> diff --git a/layouts/partials/post_nav_links.html b/layouts/partials/post_nav_links.html index 2d1eaa9..05e68a3 100644 --- a/layouts/partials/post_nav_links.html +++ b/layouts/partials/post_nav_links.html @@ -1,4 +1,10 @@ -{{- $pages := where site.RegularPages "Type" "in" site.Params.mainSections }} +{{/* get pages from the current page's section */}} +{{- $sections := site.Params.mainSections }} +{{- if .Section }} + {{- $sections = slice .Section }} +{{- end }} +{{- $pages := where (where site.RegularPages "Section" "in" $sections) "Params.hidden" "!=" true }} + {{- if and (gt (len $pages) 1) (in $pages . ) }} <nav class="paginav"> {{- with $pages.Next . }} |
