aboutsummaryrefslogtreecommitdiff
path: root/themes/hugo-theme-stack/layouts/shortcodes
diff options
context:
space:
mode:
authorAlexander Neonxp Kiryukhin <i@neonxp.ru>2024-11-03 20:08:36 +0300
committerAlexander Neonxp Kiryukhin <i@neonxp.ru>2024-11-03 20:08:36 +0300
commit59c7d4567380d1a9c80e96eb958fdbdd512ce006 (patch)
tree65410cfc10dbc7d060ec23be110662d9b7f6b0e9 /themes/hugo-theme-stack/layouts/shortcodes
новая жизнь блога
Diffstat (limited to 'themes/hugo-theme-stack/layouts/shortcodes')
-rw-r--r--themes/hugo-theme-stack/layouts/shortcodes/bilibili.html23
-rw-r--r--themes/hugo-theme-stack/layouts/shortcodes/gitlab.html4
-rw-r--r--themes/hugo-theme-stack/layouts/shortcodes/quote.html15
-rw-r--r--themes/hugo-theme-stack/layouts/shortcodes/tencent.html10
-rw-r--r--themes/hugo-theme-stack/layouts/shortcodes/video.html14
-rw-r--r--themes/hugo-theme-stack/layouts/shortcodes/youtube.html13
6 files changed, 79 insertions, 0 deletions
diff --git a/themes/hugo-theme-stack/layouts/shortcodes/bilibili.html b/themes/hugo-theme-stack/layouts/shortcodes/bilibili.html
new file mode 100644
index 0000000..cb72e43
--- /dev/null
+++ b/themes/hugo-theme-stack/layouts/shortcodes/bilibili.html
@@ -0,0 +1,23 @@
+{{ $vid := (.Get 0) }}
+{{ $videopage := default 1 (.Get 1) }}
+{{ $basicQuery := querify "page" $videopage "high_quality" 1 "as_wide" 1 }}
+{{ $videoQuery := "" }}
+
+{{ if strings.HasPrefix (lower $vid) "av" }}
+ {{ $videoQuery = querify "aid" (strings.TrimPrefix "av" (lower $vid)) }}
+{{ else if strings.HasPrefix (lower $vid) "bv" }}
+ {{ $videoQuery = querify "bvid" $vid }}
+{{ else }}
+ <p>Bilibili 视频av号或BV号错误!请检查视频av号或BV号是否正确</p>
+ <p>当前视频av或BV号:{{ $vid }},视频分P:{{ $videopage }}</p>
+{{ end }}
+
+<div class="video-wrapper">
+ <iframe src="https://player.bilibili.com/player.html?{{ $basicQuery | safeURL }}&{{ $videoQuery | safeURL }}"
+ scrolling="no"
+ frameborder="no"
+ framespacing="0"
+ allowfullscreen="true"
+ >
+ </iframe>
+</div>
diff --git a/themes/hugo-theme-stack/layouts/shortcodes/gitlab.html b/themes/hugo-theme-stack/layouts/shortcodes/gitlab.html
new file mode 100644
index 0000000..b5a16cf
--- /dev/null
+++ b/themes/hugo-theme-stack/layouts/shortcodes/gitlab.html
@@ -0,0 +1,4 @@
+<script
+ type="application/javascript"
+ src="https://gitlab.com/-/snippets/{{ index .Params 0 }}.js"
+></script> \ No newline at end of file
diff --git a/themes/hugo-theme-stack/layouts/shortcodes/quote.html b/themes/hugo-theme-stack/layouts/shortcodes/quote.html
new file mode 100644
index 0000000..09bb07c
--- /dev/null
+++ b/themes/hugo-theme-stack/layouts/shortcodes/quote.html
@@ -0,0 +1,15 @@
+<blockquote>
+ <p>{{ .Inner | markdownify }}</p>
+ {{- if or (.Get "author") (.Get "source") -}}
+ <span class="cite"><span>― </span>
+ {{- if .Get "author" -}}
+ <span>
+ {{- .Get "author" -}}{{- if .Get "source" -}}, {{ end -}}
+ </span>
+ {{- end -}}
+ {{- with .Get "url" -}}<a href="{{ . }}">{{- end -}}
+ <cite>{{ .Get "source" }}</cite>
+ {{- if .Get "url" -}}</a>{{- end -}}
+ </span>
+ {{- end -}}
+</blockquote> \ No newline at end of file
diff --git a/themes/hugo-theme-stack/layouts/shortcodes/tencent.html b/themes/hugo-theme-stack/layouts/shortcodes/tencent.html
new file mode 100644
index 0000000..463dec5
--- /dev/null
+++ b/themes/hugo-theme-stack/layouts/shortcodes/tencent.html
@@ -0,0 +1,10 @@
+{{ $vid := .Get 0 }}
+<div class="video-wrapper">
+ <iframe src="https://v.qq.com/txp/iframe/player.html?vid={{ $vid }}&auto=0"
+ scrolling="no"
+ frameborder="no"
+ framespacing="0"
+ allowfullscreen="true"
+ >
+ </iframe>
+</div> \ No newline at end of file
diff --git a/themes/hugo-theme-stack/layouts/shortcodes/video.html b/themes/hugo-theme-stack/layouts/shortcodes/video.html
new file mode 100644
index 0000000..5324754
--- /dev/null
+++ b/themes/hugo-theme-stack/layouts/shortcodes/video.html
@@ -0,0 +1,14 @@
+{{- $src := .Get "src" | default (.Get 0) -}}
+<div class="video-wrapper">
+ <video
+ controls
+ src="{{- $src -}}"
+ {{ with .Get "poster" }}poster="{{- . -}}"{{ end }}
+ {{ with .Get "autoplay" }}autoplay{{ end }}
+ >
+ <p>
+ Your browser doesn't support HTML5 video. Here is a
+ <a href="{{- $src -}}">link to the video</a> instead.
+ </p>
+ </video>
+</div>
diff --git a/themes/hugo-theme-stack/layouts/shortcodes/youtube.html b/themes/hugo-theme-stack/layouts/shortcodes/youtube.html
new file mode 100644
index 0000000..2f85931
--- /dev/null
+++ b/themes/hugo-theme-stack/layouts/shortcodes/youtube.html
@@ -0,0 +1,13 @@
+{{- $pc := .Page.Site.Config.Privacy.YouTube -}}
+{{- if not $pc.Disable -}}
+{{- $ytHost := cond $pc.PrivacyEnhanced "www.youtube-nocookie.com" "www.youtube.com" -}}
+{{- $id := .Get "id" | default (.Get 0) -}}
+<div class="video-wrapper">
+ <iframe loading="lazy"
+ src="https://{{ $ytHost }}/embed/{{ $id }}{{ with .Get "autoplay" }}{{ if eq . "true" }}?autoplay=1{{ end }}{{ end }}"
+ allowfullscreen
+ title="YouTube Video"
+ >
+ </iframe>
+</div>
+{{ end -}} \ No newline at end of file