diff options
Diffstat (limited to 'layouts/_default')
| -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 |
5 files changed, 48 insertions, 17 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") }} |
