Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions layouts/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
{{- end -}}

{{- if ne $page.File nil -}}
{{- $date := "" -}}
{{- if and (eq $page.Section "blog") (not $page.Date.IsZero) -}}
{{- $date = $page.Date.Format "Jan 2, 2006" -}}
{{- end -}}
{{-
$index = $index | append (
dict
Expand All @@ -16,6 +20,7 @@
"href" $page.RelPermalink
"params" $page.Params
"kind" $page.Kind
"date" $date
"ancestors" (after 1 $ancestors)
)
-}}
Expand Down
1 change: 1 addition & 0 deletions scripts/search/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ module.exports = {
description: item.params.meta_desc,
href: item.href,
authors: item.params.authors,
date: item.date || undefined,
tags: item.params.tags,
rank: this.getRank(item),
boosted: this.isBoosted(item),
Expand Down
5 changes: 5 additions & 0 deletions theme/src/scss/_algolia.scss
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@
.description {
@apply text-xs text-gray-800 leading-relaxed;
}

.date {
@apply text-gray-600 -mt-1 mb-3;
font-size: 0.6875rem;
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions theme/src/ts/algolia/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface SearchResultHit {
ancestors?: string[];
h1?: string;
title: string;
date?: string;
}

// CSS selector of the element to convert into an autocomplete control.
Expand Down Expand Up @@ -242,6 +243,9 @@ function initAutocomplete(el: HTMLElement) {
${ labelForTag(item.section) }
</span>
</div>
${ item.date
? html`<div class="date">${ item.date }</div>`
: "" }
<div class="description">
${ item.description !== "" && components.Highlight({ hit: item, attribute: "description" }) }
</div>
Expand Down
Loading