Only include an <hgroup> in the page summary if there's a description to include

Otherwise just use an <h2>. Add .page-summary__heading to both elements and update
the styles.
This commit is contained in:
Eryn Wells 2024-10-20 09:16:43 -07:00
parent 8aaea57a2e
commit 4d9e9e1301
2 changed files with 13 additions and 8 deletions

View file

@ -18,11 +18,11 @@
margin-block-end: var(--space-xl);
}
> hgroup {
line-height: 1;
.page-summary__heading {
margin-block: 0 var(--space-xs);
h2 {
line-height: 1;
font-size: var(--text-l);
margin-block: 0;
}

View file

@ -1,18 +1,23 @@
<article class="page-summary">
<hgroup>
<h2><a href="{{ .Permalink }}">{{ .LinkTitle | markdownify }}</a></h2>
{{ if and (.Params.rendersSummary | default true) -}}
{{ if and (.Params.rendersSummary | default true) (gt (len .Description) 0) -}}
<hgroup class="page-summary__heading">
<h2><a href="{{ .Permalink }}">{{ .LinkTitle | markdownify }}</a></h2>
{{ with .Description }}
<p>{{ . | markdownify }}</p>
{{ end }}
{{ end }}
</hgroup>
</hgroup>
{{ else }}
<h2 class="page-summary__heading"><a href="{{ .Permalink }}">{{ .LinkTitle | markdownify }}</a></h2>
{{ end }}
{{- if .Date -}}
{{- partial "page/date.html" (dict "page" .) -}}
{{- end }}
{{- if ne hugo.Environment "production" -}}
{{- if not hugo.IsProduction -}}
{{ partial "page/taxonomy_draft.html" (dict "page" .) }}
{{- end -}}
{{ partial "page/taxonomy_list.html" (dict "page" . "taxonomy" "categories") }}
{{ partial "page/taxonomy_list.html" (dict "page" . "taxonomy" "tags") }}
</article>