mirror of https://github.com/onweru/compose.git

Ray
11.08.2023 a91f59280bbbe42913f8708622c6e2ece2d0aa2d
named vs positional

So far, nothing I try works on handling both named and positional params in the shortcode. Trying again.
2 files modified
10 ■■■■ changed files
exampleSite/go.sum 2 ●●●●● patch | view | raw | blame | history
layouts/shortcodes/liteyoutube.html 8 ●●●●● patch | view | raw | blame | history
exampleSite/go.sum
@@ -40,3 +40,5 @@
github.com/rwstorer/hugo-theme-compose v0.0.0-20230611014843-d3652998710e/go.mod h1:7TS3BoBV/IcLPRT2r7LyTyOqzsS5P5sXKlNpGgxdK/s=
github.com/rwstorer/hugo-theme-compose v0.0.0-20230611021301-f7396f1edb0b h1:y71DHDUESv7+42YRzsXdVoTxCDgvnw+I3Wrzjg9J1Mo=
github.com/rwstorer/hugo-theme-compose v0.0.0-20230611021301-f7396f1edb0b/go.mod h1:7TS3BoBV/IcLPRT2r7LyTyOqzsS5P5sXKlNpGgxdK/s=
github.com/rwstorer/hugo-theme-compose v0.0.0-20230611022804-cdec55a13770 h1:Kl9D/nTVK2JlmwYrcT2y6yDpoMtaRLTI6mUJtwxK0tQ=
github.com/rwstorer/hugo-theme-compose v0.0.0-20230611022804-cdec55a13770/go.mod h1:7TS3BoBV/IcLPRT2r7LyTyOqzsS5P5sXKlNpGgxdK/s=
layouts/shortcodes/liteyoutube.html
@@ -1,11 +1,13 @@
{{ if .IsNamedParams }} <!-- check if using named parameters or not -->
{{ if .IsNamedParams }}
  {{ $videoid := .Get "videoid" }} <!-- required. -->
  {{ $img := .Get "img" }} <!-- not required. The initial background image instead of a generated one. -->
  {{ $params := .Get "params" }} <!-- not required. List of params here: https://developers.google.com/youtube/player_parameters -->
  {{ with $img }} {{ $bkImg := absURL (printf "images/%s" $img) }} {{ end }}
  <lite-youtube videoid="{{$videoid}}"{{ with $bkImg }} style="background-image: url('{{ . }}')"{{ end }}{{ with $params }} params="{{ . }}"{{ end }}></lite-youtube>
{{ else }}
  {{ $videoid := .Get 0 }} <!-- required. -->
  {{ $img := .Get 1 }} <!-- not required. The initial background image instead of a generated one. -->
  {{ $params := .Get 2 }} <!-- not required. List of params here: https://developers.google.com/youtube/player_parameters -->
  {{ with $img }} {{ $bkImg := absURL (printf "images/%s" $img) }} {{ end }}
  <lite-youtube videoid="{{$videoid}}"{{ with $bkImg }} style="background-image: url('{{ . }}')"{{ end }}{{ with $params }} params="{{ . }}"{{ end }}></lite-youtube>
{{ end }}
{{ with $img }} {{ $bkImg := absURL (printf "images/%s" $img) }} {{ end }}
<lite-youtube videoid="{{$videoid}}"{{ with $bkImg }} style="background-image: url('{{ . }}')"{{ end }}{{ with $params }} params="{{ . }}"{{ end }}></lite-youtube>