feat(image): add image lightgallery
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{{- $type := index . "type" | default "fa" -}}
|
||||
{{- $classList := split (index . "class") " " -}}
|
||||
{{- $scratch := index . "scratch" -}}
|
||||
{{- $context := index . "context" -}}
|
||||
{{- /* Fork Awesome */ -}}
|
||||
{{- if eq $type "fo" -}}
|
||||
{{- $newClassList := slice -}}
|
||||
@@ -12,11 +12,13 @@
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $classList = $newClassList -}}
|
||||
{{- $scratch := $context.Scratch.Get "scratch" -}}
|
||||
{{- $scratch.Set "forkawesome" true -}}
|
||||
|
||||
{{- /* default is Font Awesome */ -}}
|
||||
{{- /* Others */ -}}
|
||||
{{- else if ne $type "fa" -}}
|
||||
{{- $scratch := $context.Scratch.Get "scratch" -}}
|
||||
{{- $scratch.Set "iconfont" true -}}
|
||||
{{- end -}}
|
||||
<i class="{{ delimit $classList ` ` }}"></i>
|
||||
|
||||
@@ -1,3 +1,36 @@
|
||||
{{- /* Lazyload */ -}}
|
||||
{{- $res := resources.Get "svg/loading.svg" | minify -}}
|
||||
<img src="{{ $res.RelPermalink | safeURL }}" data-sizes="auto" data-src="{{ index . `src` | safeURL }}" alt="{{ index . `alt` }}" title="{{ index . `title` | default (index . `alt`) }}" class="lazyload">
|
||||
{{- /* lazysizes and lightgallery.js */ -}}
|
||||
{{- $src := index . "src" -}}
|
||||
{{- $small := index . "src-s" | default $src -}}
|
||||
{{- $large := index . "src-l" | default $src -}}
|
||||
{{- $title := index . "title" -}}
|
||||
{{- $description := index . "description" -}}
|
||||
{{- $context := index . "context" -}}
|
||||
{{- $scratch := $context.Scratch.Get "scratch" -}}
|
||||
{{- $loading := resources.Get "svg/loading.svg" | minify -}}
|
||||
{{- if not (index . "src") | and (index . "src-s") -}}
|
||||
{{- $loading = resources.Get "svg/loading.small.svg" | minify -}}
|
||||
{{- end -}}
|
||||
{{- if index . "lightgallery" -}}
|
||||
<a class="lightgallery" href="{{ $large | safeURL }}" title="{{ $description }}" data-thumbnail="{{ $small | safeURL }}"{{ if $title }} data-sub-html="<h2>{{ $title }}</h2><p>{{ $description }}</p>"{{ end }}>
|
||||
<img
|
||||
class="lazyload"
|
||||
loading="lazy"
|
||||
src="{{ $loading.RelPermalink | safeURL }}"
|
||||
data-sizes="auto"
|
||||
data-srcset="{{ $small | safeURL }}, {{ $src | safeURL }} 1.5x, {{ $large | safeURL }} 2x"
|
||||
data-src="{{ $src | safeURL }}"
|
||||
alt="{{ $title | default $description }}" />
|
||||
</a>
|
||||
{{- $scratch.Set "lightgallery" true -}}
|
||||
{{- else -}}
|
||||
<img
|
||||
class="lazyload"
|
||||
loading="lazy"
|
||||
src="{{ $loading.RelPermalink | safeURL }}"
|
||||
data-sizes="auto"
|
||||
data-srcset="{{ $small | safeURL }}, {{ $src | safeURL }} 1.5x, {{ $large | safeURL }} 2x"
|
||||
data-src="{{ $src | safeURL }}"
|
||||
alt="{{ $title | default $description }}"
|
||||
title="{{ $description }}" />
|
||||
{{- end -}}
|
||||
{{- $scratch.Set "lazysizes" true -}}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
{{- if .Params.share.enable | default .Site.Params.share.enable | eq true -}}
|
||||
{{- .Scratch.Set "share" true -}}
|
||||
{{- $scratch := .Scratch.Get "scratch" -}}
|
||||
|
||||
{{- if ne .Site.Params.share.enable false | and (ne .Params.share false) -}}
|
||||
{{- $scratch.Set "share" true -}}
|
||||
|
||||
{{- /* 001: Twitter */ -}}
|
||||
{{- if .Params.Share.Twitter | default .Site.Params.Share.Twitter | eq true -}}
|
||||
@@ -95,7 +97,7 @@
|
||||
{{- /* 014: Instapaper */ -}}
|
||||
{{- if .Params.Share.Instapaper | default .Site.Params.Share.Instapaper | eq true -}}
|
||||
<a href="javascript:void(0);" title="{{ T `share` }} Instapaper" data-sharer="instapaper" data-url="{{ .Permalink }}" data-title="{{ .Title }}" data-description="{{ .Description }}">
|
||||
{{- partial "plugin/icon.html" (dict "class" "loveit it-instapaper-fill" "type" "other" "scratch" .Scratch) -}}
|
||||
{{- partial "plugin/icon.html" (dict "class" "loveit it-instapaper-fill" "type" "other" "context" .) -}}
|
||||
</a>
|
||||
{{- end -}}
|
||||
|
||||
@@ -144,7 +146,7 @@
|
||||
{{- /* 021: Myspace */ -}}
|
||||
{{- if .Params.Share.Myspace | default .Site.Params.Share.Myspace | eq true -}}
|
||||
<a href="javascript:void(0);" title="{{ T `share` }} Myspace" data-sharer="myspace" data-url="{{ .Permalink }}" data-title="{{ .Title }}" data-description="{{ .Description }}">
|
||||
{{- partial "plugin/icon.html" (dict "class" "loveit it-myspace-fill" "type" "other" "scratch" .Scratch) -}}
|
||||
{{- partial "plugin/icon.html" (dict "class" "loveit it-myspace-fill" "type" "other" "context" .) -}}
|
||||
</a>
|
||||
{{- end -}}
|
||||
|
||||
@@ -158,7 +160,7 @@
|
||||
{{- /* 023: 百度 */ -}}
|
||||
{{- if .Params.Share.Baidu | default .Site.Params.Share.Baidu | eq true -}}
|
||||
<a href="javascript:void(0);" title="{{ T `share` }} 百度" data-sharer="baidu" data-url="{{ .Permalink }}" data-title="{{ .Title }}">
|
||||
{{- partial "plugin/icon.html" (dict "class" "loveit it-baidu-fill" "type" "other" "scratch" .Scratch) -}}
|
||||
{{- partial "plugin/icon.html" (dict "class" "loveit it-baidu-fill" "type" "other" "context" .) -}}
|
||||
</a>
|
||||
{{- end -}}
|
||||
|
||||
|
||||
@@ -302,7 +302,7 @@
|
||||
{{- /* 044: 知乎 */ -}}
|
||||
{{- with .Site.Params.Social.Zhihu -}}
|
||||
{{- $options := dict "href" (printf "https://www.zhihu.com/people/%s" .) "title" "知乎" "rel" "me" -}}
|
||||
{{- $options = dict "icon" (dict "class" "loveit it-zhihu-line" "type" "other" "scratch" $.Scratch) | merge $options -}}
|
||||
{{- $options = dict "icon" (dict "class" "loveit it-zhihu-line" "type" "other" "context" $) | merge $options -}}
|
||||
{{- partial "plugin/link.html" $options -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -394,28 +394,28 @@
|
||||
{{- /* 055: Gitea */ -}}
|
||||
{{- with .Site.Params.Social.Gitea -}}
|
||||
{{- $options := dict "href" . "title" "Gitea" "rel" "me" -}}
|
||||
{{- $options = dict "icon" (dict "class" "fa fa-gitea fa-fw" "type" "fo" "scratch" $.Scratch) | merge $options -}}
|
||||
{{- $options = dict "icon" (dict "class" "fa fa-gitea fa-fw" "type" "fo" "context" $) | merge $options -}}
|
||||
{{- partial "plugin/link.html" $options -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* 056: XMPP */ -}}
|
||||
{{- with .Site.Params.Social.XMPP -}}
|
||||
{{- $options := dict "href" (printf "xmpp:%s" .) "title" "XMPP" "rel" "me" -}}
|
||||
{{- $options = dict "icon" (dict "class" "fa fa-xmpp fa-fw" "type" "fo" "scratch" $.Scratch) | merge $options -}}
|
||||
{{- $options = dict "icon" (dict "class" "fa fa-xmpp fa-fw" "type" "fo" "context" $) | merge $options -}}
|
||||
{{- partial "plugin/link.html" $options -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* 057: Matrix */ -}}
|
||||
{{- with .Site.Params.Social.Matrix -}}
|
||||
{{- $options := dict "href" (printf "https://matrix.to/#/%s" .) "title" "Matrix" "rel" "me" -}}
|
||||
{{- $options = dict "icon" (dict "class" "fa fa-matrix-org fa-fw" "type" "fo" "scratch" $.Scratch) | merge $options -}}
|
||||
{{- $options = dict "icon" (dict "class" "fa fa-matrix-org fa-fw" "type" "fo" "context" $) | merge $options -}}
|
||||
{{- partial "plugin/link.html" $options -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* 058: bilibili */ -}}
|
||||
{{- with .Site.Params.Social.Bilibili -}}
|
||||
{{- $options := dict "href" (printf "https://space.bilibili.com/%s" .) "title" "bilibili" "rel" "me" -}}
|
||||
{{- $options = dict "icon" (dict "class" "loveit it-bilibili-fill" "type" "other" "scratch" $.Scratch) | merge $options -}}
|
||||
{{- $options = dict "icon" (dict "class" "loveit it-bilibili-fill" "type" "other" "context" $) | merge $options -}}
|
||||
{{- partial "plugin/link.html" $options -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user