Skip to content

Commit d7be807

Browse files
authored
Merge pull request #46706 from mariasalcedo/fix/glossary-definition
fix(shortcode): Amend glossary definition shortcode
2 parents a78d151 + 3144f20 commit d7be807

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

layouts/shortcodes/glossary_definition.html

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,16 @@
55
{{- $glossaryItems := $glossaryBundle.Resources.ByType "page" -}}
66
{{- $term_info := $glossaryItems.GetMatch (printf "%s.md" $id ) -}}
77
{{- $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 -}}
118
{{- if or (eq "long" $length) (eq "all" $length) -}}
129
{{- $showFullDefinition = true -}}
1310
{{- else if (eq "short" $length) -}}
1411
{{- $showFullDefinition = false -}}
1512
{{- else -}}
1613
{{- errorf "[%s] %q: invalid glossary definition length %q" site.Language.Lang .Page.Path $length -}}
1714
{{- end -}}
18-
{{- with $term_info.Content -}}
15+
{{- with $term_info -}}
1916
{{- if not $showFullDefinition -}}
20-
{{- $firstPara := index (findRE "(?s)<p>.*?</p>" . 1) 0 -}}
17+
{{- $firstPara := index (findRE "(?s)<p>.*?</p>" .Content 1) 0 -}}
2118
{{- $firstPara := $firstPara | strings.TrimSuffix "</p>" | strings.TrimPrefix "<p>" -}}
2219
{{- $first := slicestr $firstPara 0 1 | lower -}}
2320
{{- if $prepend -}}
@@ -28,13 +25,15 @@
2825
{{- end -}}
2926
{{- else -}}
3027
{{- if $prepend -}}
31-
{{- $firstPara := index (findRE "(?s)<p>.*?</p>" . 1) 0 -}}
28+
{{- $firstPara := index (findRE "(?s)<p>.*?</p>" .Content 1) 0 -}}
3229
{{- $firstPara := $firstPara | strings.TrimSuffix "</p>" | strings.TrimPrefix "<p>" -}}
3330
{{- $first := slicestr $firstPara 0 1 | lower -}}
3431
{{- $prepended := printf "<p>%s %s%s</p>" $prepend $first (slicestr $firstPara 1) -}}
35-
{{- replace . $firstPara $prepended | safeHTML -}}
32+
{{- replace .Content $firstPara $prepended | safeHTML -}}
3633
{{- else -}}
37-
{{- . -}}
34+
{{- .Content -}}
3835
{{- end -}}
3936
{{- 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 -}}
4039
{{- end -}}

0 commit comments

Comments
 (0)