Skip to content

Commit

Permalink
perf: cache page summaries (#873)
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Jun 4, 2024
1 parent 0d00c7e commit eb6c629
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
21 changes: 2 additions & 19 deletions layouts/partials/hb/modules/blog/post/card.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,8 @@
</div>
{{- end }}
{{- if $showSummary }}
{{- $summary := $page.Summary }}
{{- $truncated := $page.Truncated }}
{{- with $page.Description }}
{{- $summary = . }}
{{- $truncated := true }}
{{- end }}
<div class="hb-blog-post-summary card-text text-secondary mb-auto">
{{- $summary -}}
</div>
{{- if and $readMore $truncated }}
<div class="mt-2">
<a
class="text-secondary"
href="{{ $url }}"
{{ if $external }}target="_blank" rel="external"{{ end }}>
{{- i18n "read_more_about" $page.Title -}}
</a>
</div>
{{- end }}
{{- $summaryCtx := dict "Page" $page "ReadMore" $readMore "External" $external "URL" $url }}
{{ partialCached "hb/modules/blog/post/summary" $summaryCtx $summaryCtx }}
{{- end }}
</div>
{{- if and $thumbnail (ne $thumbnailPos "top") }}
Expand Down
19 changes: 19 additions & 0 deletions layouts/partials/hb/modules/blog/post/summary.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{- $summary := .Page.Summary }}
{{- $truncated := .Page.Truncated }}
{{- with .Page.Description }}
{{- $summary = . }}
{{- $truncated := true }}
{{- end }}
<div class="hb-blog-post-summary card-text text-secondary mb-auto">
{{- $summary -}}
</div>
{{- if and .ReadMore $truncated }}
<div class="mt-2">
<a
class="text-secondary"
href="{{ .URL }}"
{{ if $.External }}target="_blank" rel="external"{{ end }}>
{{- i18n "read_more_about" .Page.Title -}}
</a>
</div>
{{- end }}

0 comments on commit eb6c629

Please sign in to comment.