From 5ac2552e7c5f8cff0bf0f34c9cbc42bf8d344f45 Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Fri, 1 Jan 2021 13:12:23 +0100 Subject: [PATCH 1/2] fix(widget/search): remove hardcoded form action --- layouts/partials/widget/search.html | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/layouts/partials/widget/search.html b/layouts/partials/widget/search.html index 2275eb9..833f740 100644 --- a/layouts/partials/widget/search.html +++ b/layouts/partials/widget/search.html @@ -1,10 +1,16 @@ -
-

- - - - -

-
\ No newline at end of file +{{- $query := first 1 (where .Site.Pages "Layout" "==" "search") -}} +{{- if $query -}} + {{- $searchPage := index $query 0 -}} +
+

+ + + + +

+
+{{- else -}} + {{- warnf "Search page not found. Create a page with layout: search." -}} +{{- end -}} \ No newline at end of file From efa3452cdbabe25984aea87472fb135ec0fd755e Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Fri, 1 Jan 2021 13:16:11 +0100 Subject: [PATCH 2/2] refactor(widget/archives): remove .widgets.archives.path config The theme will automatically detect the permalink to the archives page. --- exampleSite/config.yaml | 3 +- layouts/partials/widget/archives.html | 58 +++++++++++++++------------ 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index a0266c8..fb89f51 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -60,7 +60,6 @@ params: archives: limit: 5 - path: archives tagCloud: limit: 10 @@ -82,7 +81,7 @@ params: colorScheme: # Display toggle toggle: true - + # Available values: auto, light, dark default: auto diff --git a/layouts/partials/widget/archives.html b/layouts/partials/widget/archives.html index 950dbf2..4a92a30 100644 --- a/layouts/partials/widget/archives.html +++ b/layouts/partials/widget/archives.html @@ -1,27 +1,33 @@ -
-
- {{ partial "helper/icon" "infinity" }} -
-

{{ T "widget.archives.title" }}

+{{- $query := first 1 (where .Site.Pages "Layout" "==" "archives") -}} +{{- if $query -}} + {{- $archivesPage := index $query 0 -}} +
+
+ {{ partial "helper/icon" "infinity" }} +
+

{{ T "widget.archives.title" }}

- {{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }} - {{ $notHidden := where .Site.RegularPages "Params.hidden" "!=" true }} - {{ $filtered := ($pages | intersect $notHidden) }} - {{ $archives := $filtered.GroupByDate "2006" }} - -
- {{ range $index, $item := first (add .Site.Params.widgets.archives.limit 1) ($archives) }} - {{- $id := lower (replace $item.Key " " "-") -}} - - {{ end }} -
-
\ No newline at end of file + {{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }} + {{ $notHidden := where .Site.RegularPages "Params.hidden" "!=" true }} + {{ $filtered := ($pages | intersect $notHidden) }} + {{ $archives := $filtered.GroupByDate "2006" }} + +
+ {{ range $index, $item := first (add .Site.Params.widgets.archives.limit 1) ($archives) }} + {{- $id := lower (replace $item.Key " " "-") -}} + + {{ end }} +
+
+{{- else -}} + {{- warnf "Archives page not found. Create a page with layout: archives." -}} +{{- end -}} \ No newline at end of file