diff options
author | otis <xiaohei.zyx@gmail.com> | 2019-11-20 14:08:26 +0300 |
---|---|---|
committer | Zhao YunXiang <xiaohei.zyx@gmail.com> | 2019-11-20 14:11:26 +0300 |
commit | 2d3aa464e0ce6ca9b982588a91fd29dbd84b91a7 (patch) | |
tree | 223a8ba914b79bfeac998fda1c87f5e4a3d688b0 /layouts | |
parent | 43265bbb6d128aa05092decbd75441df39eacafe (diff) |
avoid hard code
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/_default/baseof.html | 7 | ||||
-rw-r--r-- | layouts/_default/list.searchindex.json | 3 | ||||
-rw-r--r-- | layouts/index.html | 3 | ||||
-rw-r--r-- | layouts/partials/_widgets/recent_posts.html | 2 | ||||
-rw-r--r-- | layouts/partials/pagination.html | 2 | ||||
-rw-r--r-- | layouts/partials/script.html | 2 |
6 files changed, 14 insertions, 5 deletions
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index bdedf17..05b0d70 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -26,6 +26,13 @@ {{- if eq .Site.Params.sidebar "none"}} {{- $.Scratch.Add "bodyClass" "no-sidebar" }} {{- end }} + <!-- gen regular pages by mainSections --> + {{- if and (.Site.Params.mainSections) (ge (len .Site.Params.mainSections) 0) }} + {{- $.Scratch.Add "pages" (where .Site.RegularPages "Type" "in" .Site.Params.mainSections) }} + {{- else }} + {{- $.Scratch.Add "pages" (.Site.RegularPages) }} + {{- end }} + <body class="{{- delimit ( $.Scratch.Get "bodyClass" ) " " }}" itemscope itemtype="http://schema.org/WebPage"> {{- partial "header.html" .}} {{- if and (.Site.Params.sidebar) (or (ne .Params.sidebar "none") (ne .Params.sidebar "custom"))}} diff --git a/layouts/_default/list.searchindex.json b/layouts/_default/list.searchindex.json index 4e93e79..cf2f165 100644 --- a/layouts/_default/list.searchindex.json +++ b/layouts/_default/list.searchindex.json @@ -7,7 +7,8 @@ {{- $.Scratch.Add "tags" (dict "title" .Page.Title "uri" .Page.Permalink) -}} {{- end -}} {{- $.Scratch.Add "posts" slice -}} -{{- range $index, $element := (where .Site.RegularPages "Type" "posts") -}} + +{{- range $index, $element := $.Scratch.Get "pages" -}} {{- $.Scratch.Add "posts" (dict "id" $index "title" $element.Title "uri" $element.Permalink "tags" $element.Params.tags "section" $element.Section "content" $element.Plain "summary" $element.Summary "year" ($element.Date.Format "2006")) -}} {{- end -}} {{- $.Scratch.SetInMap "searchindex" "posts" ($.Scratch.Get "posts") }} diff --git a/layouts/index.html b/layouts/index.html index 60a1cce..1e3beeb 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -3,7 +3,8 @@ <main class="main" role="main"> {{/* partial "archive-list.html" . - */}} <div class="content article-list"> - {{- range where .Site.RegularPages "Type" "posts" -}} + <!-- {{- print ($.Scratch.Get "pages") }} --> + {{- range $.Scratch.Get "pages" }} <article class="article article-type-page" itemscope diff --git a/layouts/partials/_widgets/recent_posts.html b/layouts/partials/_widgets/recent_posts.html index 4546d8c..5240218 100644 --- a/layouts/partials/_widgets/recent_posts.html +++ b/layouts/partials/_widgets/recent_posts.html @@ -3,7 +3,7 @@ <h3 class="widget-title">{{T "widget_recent_posts" }}</h3> <div class="widget-body"> <ul class="recent-post-list list-unstyled no-thumbnail"> - {{- range first 5 (where $.Site.RegularPages "Type" "posts") }} + {{- range first 5 ($.Scratch.Get "pages") }} <li> <div class="item-inner"> <p class="item-title"> diff --git a/layouts/partials/pagination.html b/layouts/partials/pagination.html index 5dabfca..08d5f29 100644 --- a/layouts/partials/pagination.html +++ b/layouts/partials/pagination.html @@ -1,4 +1,4 @@ -{{- $paginator := .Paginate (where .RegularPages "Type" "posts") -}} +{{- $paginator := .Paginate $.Scratch.Get "pages" -}} <nav class="bar bar-footer clearfix" data-stick-bottom> <div class="bar-inner"> <ul class="pager pull-left"> diff --git a/layouts/partials/script.html b/layouts/partials/script.html index f0d3219..13ccb61 100644 --- a/layouts/partials/script.html +++ b/layouts/partials/script.html @@ -41,7 +41,7 @@ hljs.initHighlightingOnLoad(); {{- if .IsPage }} {{- partial "_script/pv.html" . }} {{- end }} -{{- if eq .Type "posts" }} +{{- if in $.Site.Params.mainSections .Type }} {{- partial "_script/comment.html" . }} {{- end }} {{- partial "_script/fancybox.html" . }} |