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
12 changes: 8 additions & 4 deletions layouts/_default/list.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{{ partial "markdown/front-matter.md" . }}
{{- $body := partial "markdown/body.md" . }}
{{ with $body }}{{ . }}

{{ end -}}
{{ $body }}
{{- /* Leave out the children that the body already links, for example in a
link group, so the page does not list them twice. */ -}}
{{- $unlinked := slice -}}
Expand All @@ -11,7 +9,13 @@
{{- $unlinked = $unlinked | append . -}}
{{- end -}}
{{- end -}}
{{- with $unlinked -}}
{{- /* End the body with a newline, and add a blank line before the list.
A page with no body needs neither. */ -}}
{{- if $body }}
{{ end -}}
{{- with $unlinked }}
{{- if $body }}
{{ end -}}
## Pages in this section

{{ range . -}}
Expand Down
12 changes: 12 additions & 0 deletions layouts/partials/markdown/body.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,16 @@
{{- end -}}
{{- end -}}
{{- end -}}
{{- /* Shortcodes and their source leave runs of blank lines. One blank line
separates blocks just as well and costs fewer tokens. Keep the runs
inside fenced code, where they are part of the sample: swap each
fence for a placeholder, collapse the runs, and swap the fences back. */ -}}
{{- $fences := findRE "(?ms)^[ \t]*```.*?^[ \t]*```[ \t]*$" $body -}}
{{- range $i, $fence := $fences -}}
{{- $body = replace $body $fence (printf "\x00%d\x00" $i) -}}
{{- end -}}
{{- $body = replaceRE `\n([ \t]*\n){2,}` "\n\n" $body -}}
{{- range $i, $fence := $fences -}}
{{- $body = replace $body (printf "\x00%d\x00" $i) $fence -}}
{{- end -}}
{{- $body | strings.TrimSpace -}}
Loading