From f7396f1edb0b52689dcd0a0674a84c40c40440e3 Mon Sep 17 00:00:00 2001
From: Ray <rwstorer@hotmail.com>
Date: Sun, 11 Jun 2023 02:13:01 +0000
Subject: [PATCH] with and no params

---
 layouts/shortcodes/liteyoutube.html            |   16 ++++++++++------
 exampleSite/content/docs/compose/shortcodes.md |   12 +++++++-----
 exampleSite/go.sum                             |    2 ++
 3 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/exampleSite/content/docs/compose/shortcodes.md b/exampleSite/content/docs/compose/shortcodes.md
index d004017..2e8b40b 100644
--- a/exampleSite/content/docs/compose/shortcodes.md
+++ b/exampleSite/content/docs/compose/shortcodes.md
@@ -78,13 +78,15 @@
 | params | YouTube parameters | yes |
 | img | Background image from static/images | yes |
 
-##### With only `videoid`
+##### With no Parameters
+
+This example shows only supplying the required `videoid` (without a named parameter). You can also add the `img` and `params` parameters (in that order) without using named parameters.
 
 ```markdown
-{{</* liteyoutube videoid="MmG2ah5Df4g" */>}}
+{{</* liteyoutube "MmG2ah5Df4g" */>}}
 ```
 
-{{< liteyoutube videoid="MmG2ah5Df4g" >}}
+{{< liteyoutube "MmG2ah5Df4g" >}}
 
 ##### With `videoid` and `params`
 
@@ -99,10 +101,10 @@
 ##### With All Three Parameters
 
 ```markdown
-{{</* liteyoutube videoid="MmG2ah5Df4g" img="painting.jpg" params="controls=0&start=10&end=30&modestbranding=2&rel=0&enablejsapi=1" */>}}
+{{</* liteyoutube "MmG2ah5Df4g" "painting.jpg" "controls=0&start=10&end=30&modestbranding=2&rel=0&enablejsapi=1" */>}}
 ```
 
-{{< liteyoutube videoid="MmG2ah5Df4g" img="painting.jpg" params="controls=0&start=10&end=30&modestbranding=2&rel=0&enablejsapi=1" >}}
+{{< liteyoutube "MmG2ah5Df4g" "painting.jpg" "controls=0&start=10&end=30&modestbranding=2&rel=0&enablejsapi=1" >}}
 
 {{< tip >}}
 You can browse the full list of YouTube parameters [here](https://developers.google.com/youtube/player_parameters#Parameters)
diff --git a/exampleSite/go.sum b/exampleSite/go.sum
index df6ad41..afef3b2 100644
--- a/exampleSite/go.sum
+++ b/exampleSite/go.sum
@@ -36,3 +36,5 @@
 github.com/rwstorer/hugo-theme-compose v0.0.0-20230611013609-aeaea2852b98/go.mod h1:7TS3BoBV/IcLPRT2r7LyTyOqzsS5P5sXKlNpGgxdK/s=
 github.com/rwstorer/hugo-theme-compose v0.0.0-20230611013841-e25e31add480 h1:m+9tc/4S8keQy3IhvdtzlZf0T2rW8LIHBkTD6qS40kM=
 github.com/rwstorer/hugo-theme-compose v0.0.0-20230611013841-e25e31add480/go.mod h1:7TS3BoBV/IcLPRT2r7LyTyOqzsS5P5sXKlNpGgxdK/s=
+github.com/rwstorer/hugo-theme-compose v0.0.0-20230611014843-d3652998710e h1:X7/nJFMOqLwYy0a/QPHDxQ1Mq6hJHNI+Tv8xWyBU9Bk=
+github.com/rwstorer/hugo-theme-compose v0.0.0-20230611014843-d3652998710e/go.mod h1:7TS3BoBV/IcLPRT2r7LyTyOqzsS5P5sXKlNpGgxdK/s=
diff --git a/layouts/shortcodes/liteyoutube.html b/layouts/shortcodes/liteyoutube.html
index 460d627..b2b4f6c 100644
--- a/layouts/shortcodes/liteyoutube.html
+++ b/layouts/shortcodes/liteyoutube.html
@@ -1,7 +1,11 @@
-{{ $videoid := .Get "videoid" }}
-{{ $params := .Get "params" }} <!-- not required. List of params here: https://developers.google.com/youtube/player_parameters -->
-{{ $img := .Get "img"}} <!-- not required. The initial background image instead of a generated one. -->
-{{ if $img }}
-  {{ $bkImg := absURL (printf "images/%s" $img) }}
+{{ if .IsNamedParams }} <!-- check if using named parameters or not -->
+  {{ $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 -->
+{{ 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 -->
 {{ end }}
-<lite-youtube videoid="{{$videoid}}"{{ if $img }} style="background-image: url('{{$bkImg}}')"{{ end }}{{ if $params }} params="{{$params}}"{{ end }}></lite-youtube>
\ No newline at end of file
+{{ $bkImg := absURL (printf "images/%s" $img) }}
+<lite-youtube videoid="{{$videoid}}"{{ with $bkImg }} style="background-image: url('{{ . }}')"{{ end }}{{ with $params }} params="{{ . }}"{{ end }}></lite-youtube>
\ No newline at end of file

--
Gitblit v1.10.0