|
5 | 5 | {{- $glossaryItems := $glossaryBundle.Resources.ByType "page" -}}
|
6 | 6 | {{- $term_info := $glossaryItems.GetMatch (printf "%s.md" $id ) -}}
|
7 | 7 | {{- $showFullDefinition := false -}}
|
8 |
| -{{- if not $term_info -}} |
9 |
| - {{- errorf "[%s] %q: %q is not a valid glossary term_id, see ./docs/reference/glossary/* for a full list" site.Language.Lang .Page.Path $id -}} |
10 |
| -{{- end -}} |
11 | 8 | {{- if or (eq "long" $length) (eq "all" $length) -}}
|
12 | 9 | {{- $showFullDefinition = true -}}
|
13 | 10 | {{- else if (eq "short" $length) -}}
|
14 | 11 | {{- $showFullDefinition = false -}}
|
15 | 12 | {{- else -}}
|
16 | 13 | {{- errorf "[%s] %q: invalid glossary definition length %q" site.Language.Lang .Page.Path $length -}}
|
17 | 14 | {{- end -}}
|
18 |
| -{{- with $term_info.Content -}} |
| 15 | +{{- with $term_info -}} |
19 | 16 | {{- if not $showFullDefinition -}}
|
20 |
| - {{- $firstPara := index (findRE "(?s)<p>.*?</p>" . 1) 0 -}} |
| 17 | + {{- $firstPara := index (findRE "(?s)<p>.*?</p>" .Content 1) 0 -}} |
21 | 18 | {{- $firstPara := $firstPara | strings.TrimSuffix "</p>" | strings.TrimPrefix "<p>" -}}
|
22 | 19 | {{- $first := slicestr $firstPara 0 1 | lower -}}
|
23 | 20 | {{- if $prepend -}}
|
|
28 | 25 | {{- end -}}
|
29 | 26 | {{- else -}}
|
30 | 27 | {{- if $prepend -}}
|
31 |
| - {{- $firstPara := index (findRE "(?s)<p>.*?</p>" . 1) 0 -}} |
| 28 | + {{- $firstPara := index (findRE "(?s)<p>.*?</p>" .Content 1) 0 -}} |
32 | 29 | {{- $firstPara := $firstPara | strings.TrimSuffix "</p>" | strings.TrimPrefix "<p>" -}}
|
33 | 30 | {{- $first := slicestr $firstPara 0 1 | lower -}}
|
34 | 31 | {{- $prepended := printf "<p>%s %s%s</p>" $prepend $first (slicestr $firstPara 1) -}}
|
35 |
| - {{- replace . $firstPara $prepended | safeHTML -}} |
| 32 | + {{- replace .Content $firstPara $prepended | safeHTML -}} |
36 | 33 | {{- else -}}
|
37 |
| - {{- . -}} |
| 34 | + {{- .Content -}} |
38 | 35 | {{- end -}}
|
39 | 36 | {{- end -}}
|
| 37 | +{{- else -}} |
| 38 | + {{- errorf "[%s] %q: %q is not a valid glossary term_id, see ./docs/reference/glossary/* for a full list" site.Language.Lang .Page.Path $id -}} |
40 | 39 | {{- end -}}
|
0 commit comments