Browse Source

two more shortcodes

main
Nicolas Massé 4 years ago
parent
commit
ce6a11b294
  1. 7
      layouts/shortcodes/highlightWithTitle.html
  2. 18
      layouts/shortcodes/internalLink.html

7
layouts/shortcodes/highlightWithTitle.html

@ -0,0 +1,7 @@
<!-- This shortcode renders an code block prefixed by a filename -->
<div class="highlightedFile">
{{- with .Get 0 -}}
<div class="filename">{{ . | safeHTML }}</div>
{{- end -}}
{{- highlight (trim .Inner "\n") (.Get 1) (.Get 2) -}}
</div>

18
layouts/shortcodes/internalLink.html

@ -0,0 +1,18 @@
<!-- This shortcode the HTML link to a localized resource -->
{{ $path := .Get "path" }}
{{ $lang := .Get "lang" }}
{{ $currentLang := .Page.Lang }}
{{ range .Page.Sites }}
{{ if eq .Language.Lang $lang }}
{{ with .GetPage $path }}
<a href="{{ .RelPermalink }}">
{{ .Title }}
</a>
{{ if ne $currentLang $lang }}
{{- partial "icons/en.svg" . -}}
{{ end }}
{{ else }}
{{ errorf "shortcode internalLink: Cannot find page %q with lang %q" $path $lang }}
{{ end }}
{{ end }}
{{ end }}
Loading…
Cancel
Save