feat(glossary): provide basic term glossary (#869)
* feat(glossary): provide basic term glossary Enabled a site-wide terminology glossary. * Added the `term` shortcode displaying term definition. * Added the /glossary page showing all term definitions. * Enabled a simplistic search of term definitions. * refactor(glossary): update glossary page links and add callout for Hugo support - Removed the glossary entry from the menu and adjusted weights for subsequent items. - Added informational callouts in the glossary documentation for multiple languages, directing users to the Hugo Glossary Quick Reference. - Updated links in the glossary documentation to point to the correct pages. * fix(glossary): update links to glossary page format across multiple languages - Changed links in the glossary documentation to use Hugo's relref format for consistency. - Updated links in Persian, Japanese, English, and Simplified Chinese glossary pages. --------- Co-authored-by: Xin <5097752+imfing@users.noreply.github.com> Co-authored-by: Xin <xin@imfing.com>
This commit is contained in:
32
layouts/_shortcodes/term.html
Normal file
32
layouts/_shortcodes/term.html
Normal file
@@ -0,0 +1,32 @@
|
||||
{{- /*
|
||||
Highlight a glossary term
|
||||
|
||||
@param {string} entry Either the glossary abbreviation or the term.
|
||||
|
||||
or
|
||||
|
||||
@param {string} 0 Either the glossary abbreviation or the term.
|
||||
|
||||
@example {{< term entry="MAC" >}}
|
||||
@example {{< term "MAC" >}}
|
||||
*/ -}}
|
||||
|
||||
{{- $entry := .Get "entry" | default (.Get 0) -}}
|
||||
{{- $entryLower := lower $entry -}}
|
||||
{{- $match := dict -}}
|
||||
|
||||
<!-- Go over the term data file - data/<lang>/termbase.yaml -->
|
||||
{{- range (index .Site.Data .Site.Language.Lang "termbase") -}}
|
||||
{{- if or (eq (lower .abbr) $entryLower) (eq (lower .term) $entryLower) -}}
|
||||
{{- $match = . -}}
|
||||
{{- break -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- with $match }}
|
||||
<abbr title="{{ .definition | plainify }}">
|
||||
{{- $entry -}}
|
||||
</abbr>
|
||||
{{- else }}
|
||||
{{- $entry -}}
|
||||
{{- end }}
|
||||
Reference in New Issue
Block a user