Merge pull request #109 from CaiJimmy/refactor-widget
feat(widget): detect automatically path to archives / search page
This commit is contained in:
commit
ced387cbd5
@ -60,7 +60,6 @@ params:
|
|||||||
|
|
||||||
archives:
|
archives:
|
||||||
limit: 5
|
limit: 5
|
||||||
path: archives
|
|
||||||
|
|
||||||
tagCloud:
|
tagCloud:
|
||||||
limit: 10
|
limit: 10
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<section class="widget archives">
|
{{- $query := first 1 (where .Site.Pages "Layout" "==" "archives") -}}
|
||||||
|
{{- if $query -}}
|
||||||
|
{{- $archivesPage := index $query 0 -}}
|
||||||
|
<section class="widget archives">
|
||||||
<div class="widget-icon">
|
<div class="widget-icon">
|
||||||
{{ partial "helper/icon" "infinity" }}
|
{{ partial "helper/icon" "infinity" }}
|
||||||
</div>
|
</div>
|
||||||
@ -13,7 +16,7 @@
|
|||||||
{{ range $index, $item := first (add .Site.Params.widgets.archives.limit 1) ($archives) }}
|
{{ range $index, $item := first (add .Site.Params.widgets.archives.limit 1) ($archives) }}
|
||||||
{{- $id := lower (replace $item.Key " " "-") -}}
|
{{- $id := lower (replace $item.Key " " "-") -}}
|
||||||
<div class="archives-year">
|
<div class="archives-year">
|
||||||
<a href="{{ $.Site.Params.widgets.archives.path | relLangURL }}#{{ $id }}">
|
<a href="{{ $archivesPage.RelPermalink }}#{{ $id }}">
|
||||||
{{ if eq $index $.Site.Params.widgets.archives.limit }}
|
{{ if eq $index $.Site.Params.widgets.archives.limit }}
|
||||||
<span class="year">{{ T "widget.archives.more" }}</span>
|
<span class="year">{{ T "widget.archives.more" }}</span>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
@ -24,4 +27,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
{{- else -}}
|
||||||
|
{{- warnf "Archives page not found. Create a page with layout: archives." -}}
|
||||||
|
{{- end -}}
|
@ -1,10 +1,16 @@
|
|||||||
<form action="/search" class="search-form widget" {{ with .OutputFormats.Get "json" -}}data-json="{{ .Permalink }}" {{- end }}>
|
{{- $query := first 1 (where .Site.Pages "Layout" "==" "search") -}}
|
||||||
|
{{- if $query -}}
|
||||||
|
{{- $searchPage := index $query 0 -}}
|
||||||
|
<form action="{{ $searchPage.RelPermalink }}" class="search-form widget" {{ with .OutputFormats.Get "json" -}}data-json="{{ .Permalink }}" {{- end }}>
|
||||||
<p>
|
<p>
|
||||||
<label>{{ T "search.title" }}</label>
|
<label>{{ T "search.title" }}</label>
|
||||||
<input name="keyword" required placeholder="{{ T `search.placeholder` }}" />
|
<input name="keyword" required placeholder="{{ T `search.placeholder` }}" />
|
||||||
|
|
||||||
<button title="Search">
|
<button title="{{ T `search.title` }}">
|
||||||
{{ partial "helper/icon" "search" }}
|
{{ partial "helper/icon" "search" }}
|
||||||
</button>
|
</button>
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
|
{{- else -}}
|
||||||
|
{{- warnf "Search page not found. Create a page with layout: search." -}}
|
||||||
|
{{- end -}}
|
Loading…
Reference in New Issue
Block a user