Skip to content

Commit

Permalink
Merge pull request #23 from michaeltlombardi/gh-22/main/add-itchio-sh…
Browse files Browse the repository at this point in the history
…ortcode

(GH-22) Add itch.io embed shortcode
  • Loading branch information
michaeltlombardi authored Jan 6, 2022
2 parents 33863a0 + 53afa66 commit 51703b8
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions layouts/shortcodes/itchio.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{- if .IsNamedParams -}}
{{- $.Scratch.Set "id" (.Get "id") -}}
{{- $.Scratch.Set "square" (.Get "square") -}}
{{- $.Scratch.Set "linkback" (.Get "linkback") -}}
{{- $.Scratch.Set "dark" (.Get "dark") -}}
{{- else -}}
{{- $.Scratch.Set "id" (.Get 0) -}}
{{- $.Scratch.Set "square" (.Get 1) -}}
{{- $.Scratch.Set "linkback" (.Get 2) -}}
{{- $.Scratch.Set "dark" (.Get 3) -}}
{{- end -}}
{{- $.Scratch.Set "url" (printf "https://itch.io/embed/%s" ($.Scratch.Get "id")) -}}
{{- if (eq ($.Scratch.Get "linkback") "true") -}}
{{- $.Scratch.Set "url" (printf "%s?linkback=true" ($.Scratch.Get "url")) -}}
{{- end -}}
{{- if (eq ($.Scratch.Get "dark") "true") -}}
{{- if strings.HasSuffix ($.Scratch.Get "url") "?linkback=true" -}}
{{- $.Scratch.Set "url" (printf "%s&dark=true" ($.Scratch.Get "url")) -}}
{{- else -}}
{{- $.Scratch.Set "url" (printf "%s?dark=true" ($.Scratch.Get "url")) -}}
{{- end -}}
{{- end -}}
{{- if (eq ($.Scratch.Get "square") "true") -}}
{{ $.Scratch.Set "width" "208"}}
{{- else -}}
{{ $.Scratch.Set "width" "552"}}
{{- end -}}

<iframe frameborder="0"
src="{{ $.Scratch.Get "url" }}"
width="{{ $.Scratch.Get "width" }}"
height="167">
</iframe>

0 comments on commit 51703b8

Please sign in to comment.