Skip to content

Commit

Permalink
fix(search): display the authors and adjust the meta style
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Jul 9, 2022
1 parent ee4ce24 commit 5cbbc9b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions assets/search/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ export class Search {
largeImg: result.item.largeImg,
permalink: result.item.permalink,
categories: result.item.categories,
authors: result.item.authors,
tags: result.item.tags,
series: result.item.series,
score: Search.formatScore(result.score),
Expand Down
15 changes: 12 additions & 3 deletions layouts/_default/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,19 @@ <h2 class="card-title search-result-title fs-4 my-2 text-surface">
<span class="post-date">{{ printf "{{date}}" }}</span>
{{- $baseURL := absLangURL "" -}}
{{- $placeholder := "{{#url}}{{.}}{{/url}}" -}}
{{- range slice "series" "categories" "tags" -}}
{{ printf "{{#%s}}" . }}
{{- range slice "authors" "series" "categories" "tags" -}}
{{- printf "{{#%s}}" . }}
<a {{ printf "href=\"%s%s/%s/\"" $baseURL . $placeholder | safeHTMLAttr }}
class="btn btn-sm btn-secondary mb-1 me-2 py-0 pe-1 post-taxonomy">{{ printf "{{.}}" }}</a>
class="btn btn-sm btn-secondary mb-1 me-2 py-0 pe-1 post-taxonomy">
{{- if eq . "authors" }}
<i class="fas fa-fw fa-user"></i>
{{- else if eq . "series" }}
<i class="fas fa-fw fa-columns"></i>
{{- else if eq . "categories" }}
<i class="fas fa-fw fa-folder"></i>
{{- end }}
{{- printf "{{.}}" }}
</a>
{{ printf "{{/%s}}" . }}
{{- end -}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/search/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
{{- $img = $featured.Permalink -}}
{{- end -}}
{{- end -}}
{{- $item := (dict "title" $title "tags" .Params.tags "categories" .Params.categories "series" .Params.series "content" .Plain "permalink" .Permalink "date" $date "img" $img "smallImg" $smallImg "largeImg" $largeImg) -}}
{{- $item := (dict "title" $title "authors" .Params.authors "tags" .Params.tags "categories" .Params.categories "series" .Params.series "content" .Plain "permalink" .Permalink "date" $date "img" $img "smallImg" $smallImg "largeImg" $largeImg) -}}
{{- $.Scratch.Add "index" $item -}}
{{- end -}}
{{- $.Scratch.Get "index" | uniq | jsonify -}}

0 comments on commit 5cbbc9b

Please sign in to comment.