Skip to content

Commit aa10ed9

Browse files
committed
hugo: improve metadata rendering for markdown output
Render title and related pages as front matter Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
1 parent 390938c commit aa10ed9

2 files changed

Lines changed: 69 additions & 5 deletions

File tree

layouts/_default/list.markdown.md

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
1-
# {{ .Title }}
1+
---
2+
title: {{ .Title }}
3+
url: {{ .Permalink }}
4+
{{- range .Ancestors }}
5+
{{- if and (not .IsHome) .Permalink }}
6+
parent:
7+
title: {{ .Title }}
8+
url: {{ .Permalink }}
9+
{{- break }}
10+
{{- end }}
11+
{{- end }}
12+
{{- if .Ancestors }}
13+
breadcrumbs:
14+
{{- range .Ancestors.Reverse }}
15+
{{- if and (not .IsHome) .Permalink }}
16+
- title: {{ .Title }}
17+
url: {{ .Permalink }}
18+
{{- end }}
19+
{{- end }}
20+
- title: {{ .Title }}
21+
url: {{ .Permalink }}
22+
{{- end }}
23+
{{- $children := where .Pages "Permalink" "ne" "" }}
24+
{{- if $children }}
25+
children:
26+
{{- range $children }}
27+
- title: {{ .Title }}
28+
url: {{ .Permalink }}
29+
{{- with .Description }}
30+
description: {{ . }}
31+
{{- end }}
32+
{{- end }}
33+
{{- end }}
34+
---
35+
236
{{ .RenderShortcodes }}
3-
{{ range where .Pages "Permalink" "ne" "" }}
4-
- [{{ .Title }}]({{ .Permalink }})
5-
{{ end }}
Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,35 @@
1-
# {{ .Title }}
1+
---
2+
title: {{ .Title }}
3+
url: {{ .Permalink }}
4+
{{- range .Ancestors }}
5+
{{- if and (not .IsHome) .Permalink }}
6+
parent:
7+
title: {{ .Title }}
8+
url: {{ .Permalink }}
9+
{{- break }}
10+
{{- end }}
11+
{{- end }}
12+
{{- if .Ancestors }}
13+
breadcrumbs:
14+
{{- range .Ancestors.Reverse }}
15+
{{- if and (not .IsHome) .Permalink }}
16+
- title: {{ .Title }}
17+
url: {{ .Permalink }}
18+
{{- end }}
19+
{{- end }}
20+
- title: {{ .Title }}
21+
url: {{ .Permalink }}
22+
{{- end }}
23+
{{- with .NextInSection }}
24+
next:
25+
title: {{ .Title }}
26+
url: {{ .Permalink }}
27+
{{- end }}
28+
{{- with .PrevInSection }}
29+
prev:
30+
title: {{ .Title }}
31+
url: {{ .Permalink }}
32+
{{- end }}
33+
---
34+
235
{{ .RenderShortcodes }}

0 commit comments

Comments
 (0)