From d67dd3fe3761936c02ae9c1ef1b30fe3e6e38ca2 Mon Sep 17 00:00:00 2001
From: Ray <rwstorer@hotmail.com>
Date: Sun, 11 Jun 2023 00:10:28 +0000
Subject: [PATCH] add liteyoutube
---
layouts/partials/head.html | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 152425e..55301c6 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -1,3 +1,17 @@
+{{ $includeLiteYT := false }} <!-- begin search for liteyoutube shortcode. code borrowed from erichc Nov 2020 https://discourse.gohugo.io/t/automagically-loading-suitable-scripts-in-head/29429/8 -->
+{{ if .IsNode }} <!-- list page -->
+ {{ range .Pages }} <!-- check child pages -->
+ {{ range .Pages }} <!-- another recursion because of the "/posts/xyz" structure; does work with category lists -->
+ {{ $rawsummary := split .RawContent "<!--more-->" }} <!-- prepare for checking only the part of the article that will show up on the list page -->
+ {{ if (findRE "{{< liteyoutube" (index $rawsummary 0)) }} <!-- check if this part uses the shortcode -->
+ {{ $includeLiteYT = true }}
+ {{ end }}
+ {{ end }} <!-- second range .Pages -->
+ {{ end }} <!-- first range .Pages -->
+{{ end }} <!-- IsNode -->
+{{ if (.HasShortcode "liteyoutube") }} <!-- check if single page or list page itself use the shortcode -->
+ {{ $includeLiteYT = true }}
+{{ end }} <!-- end liteyoutube shortcode search -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
{{- hugo.Generator }}
@@ -9,6 +23,11 @@
<link rel="mask-icon" href='{{ absURL (printf "%ssafari-pinned-tab.svg" $iconsPath) }}' color="#004750">
<link rel="shortcut icon" href='{{ absURL (printf "%sfavicon.ico" $iconsPath) }}'>
<meta name="msapplication-config" content='{{ absURL (printf "%sbrowserconfig.xml" $iconsPath) }}'>
+{{ if $includeLiteYT }} <!-- if we find the liteyoutube shortcode in the page, insert the stylesheet and the javascript into the header -->
+ <!-- the lite-yt-embed script and css retrieved from https://github.com/paulirish/lite-youtube-embed -->
+ <link rel="stylesheet" href="{{.Site.BaseURL}}/css/lite-yt-embed.css">
+ <script type="text/javascript" src="{{.Site.BaseURL}}/js/lite-yt-embed.js"></script>
+{{ end }}
{{- $t := .Title }}
{{- $s := site.Title }}
{{- if in (lower $s) (lower $t) }}
--
Gitblit v1.10.0