Adding shortcode support to add call-to-actions to pages

This commit is contained in:
Michael Boelen 2024-11-07 14:48:32 +00:00
parent 28b7208ba2
commit 6b87626781
2 changed files with 25 additions and 0 deletions

View file

@ -0,0 +1,9 @@
id: lid-worden
items:
- item: en
language: en
text: Become a member!
- item: nl
language: nl
text: Word lid!
page: "lidmaatschap/aanmelden/index.md"

View file

@ -0,0 +1,16 @@
{{ $context := . }}
{{ $id := .Get "id" }}
{{ with (index $.Site.Data.call_to_actions $id) }}
{{ $language := $.Site.Language.Lang }}
<div>
{{ $string := "Tekst" }}
{{- range $key, $value := .items -}}
{{ if eq $value.language $language }}
{{ $string = $value.text }}
{{ if .page }}<a class="button" href="{{ relref $context .page }}">{{ end }}
<span>{{ $string }}</span>
{{ if .page }}</a>{{ end }}
{{ end }}
{{ end }}
</div>
{{ end }}