feat: Adds language badges to tour overview table
Some checks failed
/ build (pull_request) Failing after 15s
Some checks failed
/ build (pull_request) Failing after 15s
This commit is contained in:
parent
4f8c6a9771
commit
d4092d97b6
4 changed files with 69 additions and 44 deletions
9
layouts/shortcodes/README.MD
Normal file
9
layouts/shortcodes/README.MD
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
## Shortcode: Language badge
|
||||
|
||||
Use the `lang` shortcode to mark whether a tour is in German, English or bilingual. It renders a small superscript badge next to the text, with details when hovered over or parsed by a screenreader.
|
||||
|
||||
- German: `{{< lang de >}}`
|
||||
- English: `{{< lang en >}}`
|
||||
- Bilingual: `{{< lang deen >}}`
|
||||
|
||||
For usage references check the [German](/content/de/39c3/_index.md) and [English](/content/en/39c3/_index.md) tour overview.
|
||||
16
layouts/shortcodes/lang.html
Normal file
16
layouts/shortcodes/lang.html
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{{- $code := .Get 0 | lower -}}
|
||||
{{- $validCodes := slice "de" "en" "deen" -}}
|
||||
{{- if not (in $validCodes $code) -}}
|
||||
<span style="color: red; font-weight: bold;">Warning: Invalid or missing language code '{{ $code }}'. Use 'de', 'en', or 'deen'.</span>
|
||||
{{- else -}}
|
||||
{{- $label := cond (eq $code "de") "DE" (cond (eq $code "en") "EN" (cond (eq $code "deen") "DE/EN" "")) -}}
|
||||
{{- $title := "" -}}
|
||||
{{- if eq $code "deen" -}}
|
||||
{{- $title = cond (eq .Site.Language.Lang "de") "Diese Tour wird zweisprachig stattfinden (Deutsch und Englisch)" "This tour will be bilingual (German and English)" -}}
|
||||
{{- else if eq $code "de" -}}
|
||||
{{- $title = cond (eq .Site.Language.Lang "de") "Diese Tour wird auf Deutsch stattfinden" "This tour will be held in German" -}}
|
||||
{{- else if eq $code "en" -}}
|
||||
{{- $title = cond (eq .Site.Language.Lang "de") "Diese Tour wird auf Englisch stattfinden" "This tour will be held in English" -}}
|
||||
{{- end -}}
|
||||
<abbr style="font-size: .65em; vertical-align: super;" title="{{ $title }}">{{ $label }}</abbr>
|
||||
{{- end -}}
|
||||
Loading…
Add table
Add a link
Reference in a new issue