Initial version
This commit is contained in:
commit
ed5653a7fc
211 changed files with 11043 additions and 0 deletions
65
themes/zen/layouts/shortcodes/svg.html
Normal file
65
themes/zen/layouts/shortcodes/svg.html
Normal file
|
@ -0,0 +1,65 @@
|
|||
{{ $alt := .Get "alt" -}}
|
||||
{{ $caption := .Get "caption" -}}
|
||||
{{ $class := .Get "class" -}}
|
||||
{{ $height := .Get "height" -}}
|
||||
{{ $inline := .Get "inline" | default false -}}
|
||||
{{ $link := .Get "link" -}}
|
||||
{{ $src := .Get "src" -}}
|
||||
{{ $width := .Get "width" -}}
|
||||
|
||||
{{ $resource := false -}}
|
||||
{{ $static := false -}}
|
||||
|
||||
{{ if and $src (fileExists (path.Join "/static" $src)) -}}
|
||||
{{ $static = true -}}
|
||||
{{ $src = relURL $src -}}
|
||||
{{ if $inline -}}
|
||||
{{ $src = readFile (path.Join "/static" $src) -}}
|
||||
{{ end -}}
|
||||
{{ else if $src -}}
|
||||
{{ $src = strings.TrimLeft "/" $src -}}
|
||||
{{ with resources.Get $src -}}
|
||||
{{ $resource = . -}}
|
||||
{{ end -}}
|
||||
{{ with .Page.Resources.Get $src -}}
|
||||
{{ $resource = . -}}
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
|
||||
{{ if $resource -}}
|
||||
{{ if $inline -}}
|
||||
{{ $src = $resource.Content -}}
|
||||
{{ else -}}
|
||||
{{ $src = $resource.RelPermalink -}}
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
|
||||
{{ if and $width $height -}}
|
||||
{{ $width = int $width -}}
|
||||
{{ $height = int $height -}}
|
||||
{{ else if $width -}}
|
||||
{{ $width = int $width -}}
|
||||
{{ else if $height -}}
|
||||
{{ $height = int $height -}}
|
||||
{{ end -}}
|
||||
|
||||
{{ if not $src -}}
|
||||
{{ warnf "%s shortcode number %d in \"content/%s\" is missing the \"src\" attribute." .Name .Ordinal .Page.File.Path -}}
|
||||
{{ else if not (or $static $resource) -}}
|
||||
{{ warnf "%s shortcode number %d in \"content/%s\" has an error in the \"src\" attribute." .Name .Ordinal .Page.File.Path -}}
|
||||
{{ end -}}
|
||||
|
||||
{{ if $caption }}<figure class="image image--svg{{ with $class }} {{ . }}{{ end }}">{{ end -}}
|
||||
{{ with $link }}<a class="image-link" href="{{ . }}">{{ end -}}
|
||||
{{ if $inline -}}
|
||||
<div class="image image--svg{{ with $class }} {{ . }}{{ end }}">{{ $src | safeHTML }}</div>
|
||||
{{ else -}}
|
||||
<img class="image image--svg{{ with $class }} {{ . }}{{ end }}" src="{{ $src }}"{{ if isset .Params "alt" }} alt="{{ $alt }}"{{ end }}{{ with $width }} width="{{ . }}"{{ end }}{{ with $height }} height="{{ . }}"{{ end }}>
|
||||
{{ end -}}
|
||||
{{- if $link }}</a>{{ end }}
|
||||
{{ if $caption -}}
|
||||
<figcaption>
|
||||
{{ $caption | markdownify -}}
|
||||
</figcaption>
|
||||
</figure>
|
||||
{{ end -}}
|
Loading…
Add table
Add a link
Reference in a new issue