diff options
author | Wang Chucheng <wangchucheng@outlook.com> | 2020-12-15 19:29:48 +0300 |
---|---|---|
committer | Wang Chucheng <wangchucheng@outlook.com> | 2020-12-15 19:29:48 +0300 |
commit | f1e1ec9f79295532a85b59c075e2ebac55951bd7 (patch) | |
tree | 467cc153ad4e8ba34d2ac065fe10c2c855e277d2 /layouts | |
parent | 69af104e562b4a2d86aff01cb9187f64a475f948 (diff) |
feat: featured videov0.3.0
Closes #15
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/_default/single.html | 8 | ||||
-rw-r--r-- | layouts/partials/doc_layout.html | 6 | ||||
-rw-r--r-- | layouts/partials/get_featured.html | 7 | ||||
-rw-r--r-- | layouts/partials/get_video.html | 7 | ||||
-rw-r--r-- | layouts/partials/horizontal_summary.html | 10 | ||||
-rw-r--r-- | layouts/partials/stacked_summary.html | 6 |
6 files changed, 30 insertions, 14 deletions
diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 3191c7e..a9053bf 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -6,12 +6,14 @@ class="col-span-2 {{ if not $hasSidebar }} {{- print "lg:col-start-2" -}} {{ end }} lg:col-span-6 bg-secondary-bg rounded px-6 py-8"> <h1 class="font-bold text-3xl text-primary-text">{{ .Title }}</h1> {{ partial "post_metadata.html" . }} - {{ $img := partial "get_image.html" (dict "context" . "url" .Params.featuredImage "keyword" "*featured*")}} - {{ with $img }} + + {{ $featured := partial "get_featured" . }} + {{ with $featured }} <div class="my-4"> - <img src="{{ . }}" class="w-full" alt="Featured Image"> + {{ . }} </div> {{ end }} + <div class="content"> {{ .Content}} </div> diff --git a/layouts/partials/doc_layout.html b/layouts/partials/doc_layout.html index beffa65..4cf57bc 100644 --- a/layouts/partials/doc_layout.html +++ b/layouts/partials/doc_layout.html @@ -15,10 +15,10 @@ </div> <div class="flex"> <div class="w-full lg:w-3/4 px-6"> - {{ $img := partial "get_image.html" (dict "context" . "url" .Params.featuredImage "keyword" "*featured*")}} - {{ with $img }} + {{ $featured := partial "get_featured" . }} + {{ with $featured }} <div class="my-4"> - <img src="{{ . }}" class="w-full" alt="Featured Image"> + {{ . }} </div> {{ end }} <div class="content"> diff --git a/layouts/partials/get_featured.html b/layouts/partials/get_featured.html new file mode 100644 index 0000000..f9fd419 --- /dev/null +++ b/layouts/partials/get_featured.html @@ -0,0 +1,7 @@ +{{ $video := partial "get_video" (dict "context" . "url" .Params.featuredVideo "keyword" "*featured*") }} +{{ $image := partial "get_image.html" (dict "context" . "url" .Params.featuredImage "keyword" "*featured*") }} +{{ if $video }} +{{ $video }} +{{ else if $image }} +<img src="{{ $image }}" class="w-full" alt="Featured Image"> +{{ end }}
\ No newline at end of file diff --git a/layouts/partials/get_video.html b/layouts/partials/get_video.html new file mode 100644 index 0000000..a0a1cd9 --- /dev/null +++ b/layouts/partials/get_video.html @@ -0,0 +1,7 @@ +{{ if or (hasPrefix .url "//") (or (hasPrefix .url "http://") (hasPrefix .url "https://")) }} +<div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;"> + <iframe src="{{ .url }}" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" frameborder="0" allowfullscreen></iframe> +</div> +{{ else if .url }} +<video class="w-full" src="{{ .url | absURL }}" controls></video> +{{ end }}
\ No newline at end of file diff --git a/layouts/partials/horizontal_summary.html b/layouts/partials/horizontal_summary.html index fd0f166..cdd4eaf 100644 --- a/layouts/partials/horizontal_summary.html +++ b/layouts/partials/horizontal_summary.html @@ -1,5 +1,5 @@ <div class="flex flex-col-reverse lg:flex-row justify-between"> - <div class="w-full"> + <div class="w-full lg:w-2/3"> <div class="my-2"> <div class="mb-4"> <a href="{{ .Permalink }}" class="font-bold text-xl hover:text-eureka">{{ .LinkTitle }}</a> @@ -33,10 +33,10 @@ {{ partial "post_metadata.html" . }} {{ end }} </div> - {{ $img := partial "get_image.html" (dict "context" . "url" .Params.featuredImage "keyword" "*featured*")}} - {{ with $img }} - <div class="lg:max-w-xs mb-4 lg:mb-0 lg:ml-8"> - <img src="{{ . }}" class="w-full" alt="Featured Image"> + {{ $featured := partial "get_featured" . }} + {{ with $featured }} + <div class="w-full lg:w-1/3 mb-4 lg:mb-0 lg:ml-8"> + {{ . }} </div> {{ end }} </div>
\ No newline at end of file diff --git a/layouts/partials/stacked_summary.html b/layouts/partials/stacked_summary.html index f82365e..b354d40 100644 --- a/layouts/partials/stacked_summary.html +++ b/layouts/partials/stacked_summary.html @@ -1,7 +1,7 @@ <div class="bg-secondary-bg rounded overflow-hidden hover:shadow-lg transition ease-in-out duration-200"> - {{ $img := partial "get_image.html" (dict "context" . "url" .Params.featuredImage "keyword" "*featured*")}} - {{ with $img }} - <img src="{{ . }}" class="w-full" alt="Featured Image"> + {{ $featured := partial "get_featured" . }} + {{ with $featured }} + {{ . }} {{ end }} <div class="px-6 pt-6"> <div class="font-bold text-xl text-primary-text mb-2"> |