form
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
<!-- Preload critical images for better performance -->
|
||||
{{- with .Params.image }}
|
||||
<link rel="preload" as="image" href="{{ . }}">
|
||||
{{- end }}
|
||||
|
||||
{{- if .IsHome }}
|
||||
<!-- Preload background image -->
|
||||
<link rel="preload" as="image" href="{{ .Site.Params.backgroundPath }}">
|
||||
{{- end }}
|
||||
@@ -1,19 +1,36 @@
|
||||
<!--
|
||||
Put this file in /layouts/shortcodes/figure.html
|
||||
Updated figure shortcode for S3 images
|
||||
NB this overrides Hugo's built-in "figure" shortcode but is backwards compatible
|
||||
Documentation and licence at https://github.com/liwenyip/hugo-easy-gallery/
|
||||
-->
|
||||
<!-- count how many times we've called this shortcode; load the css if it's the first time -->
|
||||
{{- if not ($.Page.Scratch.Get "figurecount") }}<link rel="stylesheet" href="{{ "css/hugo-easy-gallery.css" | relURL }}?v={{ now.Unix }}&update=2" />{{ end }}
|
||||
{{- $.Page.Scratch.Add "figurecount" 1 -}}
|
||||
|
||||
<!-- use either src or link-thumb for thumbnail image -->
|
||||
{{- $thumb := .Get "src" | default (printf "%s." (.Get "thumb") | replace (.Get "link") ".") }}
|
||||
|
||||
<!-- Check if image URL is already absolute (starts with http/https) -->
|
||||
{{- $thumbURL := "" }}
|
||||
{{- if or (hasPrefix $thumb "http://") (hasPrefix $thumb "https://") }}
|
||||
{{- $thumbURL = $thumb }}
|
||||
{{- else }}
|
||||
{{- $thumbURL = $thumb | relURL }}
|
||||
{{- end }}
|
||||
|
||||
{{- $linkURL := "" }}
|
||||
{{- $link := .Get "link" | default (.Get "src") }}
|
||||
{{- if or (hasPrefix $link "http://") (hasPrefix $link "https://") }}
|
||||
{{- $linkURL = $link }}
|
||||
{{- else }}
|
||||
{{- $linkURL = $link | relURL }}
|
||||
{{- end }}
|
||||
|
||||
<div class="box{{ with .Get "caption-position" }} fancy-figure caption-position-{{.}}{{end}}{{ with .Get "caption-effect" }} caption-effect-{{.}}{{end}}" {{ with .Get "width" }}style="max-width:{{.}}"{{end}}>
|
||||
<figure {{ with .Get "class" }}class="{{.}}"{{ end }} itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
|
||||
<div class="img"{{ if .Parent }} style="background-image: url('{{ $thumb | relURL }}');"{{ end }}{{ with .Get "size" }} data-size="{{.}}"{{ end }}>
|
||||
<img itemprop="thumbnail" src="{{ $thumb | relURL }}" {{ with .Get "alt" | default (.Get "caption") }}alt="{{.}}"{{ end }}/><!-- <img> hidden if in .gallery -->
|
||||
<div class="img"{{ if .Parent }} style="background-image: url('{{ $thumbURL }}');"{{ end }}{{ with .Get "size" }} data-size="{{.}}"{{ end }}>
|
||||
<img itemprop="thumbnail" src="{{ $thumbURL }}" {{ with .Get "alt" | default (.Get "caption") }}alt="{{.}}"{{ end }}/><!-- <img> hidden if in .gallery -->
|
||||
</div>
|
||||
{{ with .Get "link" | default (.Get "src") }}<a href="{{ . | relURL }}" itemprop="contentUrl"></a>{{ end }}
|
||||
{{ with $linkURL }}<a href="{{ . }}" itemprop="contentUrl"></a>{{ end }}
|
||||
{{- if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
|
||||
<figcaption>
|
||||
{{- with .Get "title" }}<h4>{{.}}</h4>{{ end }}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
<!--
|
||||
Put this file in /layouts/shortcodes/gallery.html
|
||||
Updated gallery shortcode for S3 images
|
||||
Documentation and licence at https://github.com/liwenyip/hugo-easy-gallery/
|
||||
-->
|
||||
<!-- count how many times we've called this shortcode; load the css if it's the first time -->
|
||||
{{- if not ($.Page.Scratch.Get "figurecount") }}<link rel="stylesheet" href="{{ "css/hugo-easy-gallery.css" | relURL }}?v={{ now.Unix }}&update=2" />{{ end }}
|
||||
{{- $.Page.Scratch.Add "figurecount" 1 }}
|
||||
{{ $baseURL := .Site.BaseURL }}
|
||||
|
||||
<div class="gallery caption-position-{{ with .Get "caption-position" | default "bottom" }}{{.}}{{end}} caption-effect-{{ with .Get "caption-effect" | default "slide" }}{{.}}{{end}} hover-effect-{{ with .Get "hover-effect" | default "zoom" }}{{.}}{{end}} {{ if ne (.Get "hover-transition") "none" }}hover-transition{{end}}" itemscope itemtype="http://schema.org/ImageGallery">
|
||||
{{- with (.Get "dir") -}}
|
||||
<!-- If a directory was specified, generate figures for all of the images in the directory -->
|
||||
<!-- Note: This mode is not recommended for S3 images, use individual figure shortcodes instead -->
|
||||
{{- $files := readDir (print "/static/" .) }}
|
||||
{{- range $files -}}
|
||||
<!-- skip files that aren't images, or that include the thumb suffix in their name -->
|
||||
@@ -17,10 +18,10 @@ Documentation and licence at https://github.com/liwenyip/hugo-easy-gallery/
|
||||
{{- $isimg := lower .Name | findRE "\\.(gif|jpg|jpeg|tiff|png|bmp|webp|avif|jxl)" }}<!-- is the current file an image? -->
|
||||
{{- if and $isimg (not $isthumb) }}
|
||||
{{- $caption := .Name | replaceRE "\\..*" "" | humanize }}<!-- humanized filename without extension -->
|
||||
{{- $linkURL := print $baseURL ($.Get "dir") "/" .Name | absURL }}<!-- absolute URL to hi-res image -->
|
||||
{{- $linkURL := print "/images/" .Name }}<!-- relative URL to hi-res image -->
|
||||
{{- $thumb := .Name | replaceRE "(\\.)" ($thumbext | printf "%s.") }}<!-- filename of thumbnail image -->
|
||||
{{- $thumbexists := where $files "Name" $thumb }}<!-- does a thumbnail image exist? -->
|
||||
{{- $thumbURL := print $baseURL ($.Get "dir") "/" $thumb | absURL }}<!-- absolute URL to thumbnail image -->
|
||||
{{- $thumbURL := print "/images/" $thumb }}<!-- relative URL to thumbnail image -->
|
||||
<div class="box">
|
||||
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
|
||||
<div class="img" style="background-image: url('{{ if $thumbexists }}{{ $thumbURL }}{{ else }}{{ $linkURL }}{{ end }}');" >
|
||||
@@ -40,3 +41,5 @@ Documentation and licence at https://github.com/liwenyip/hugo-easy-gallery/
|
||||
{{- end }}
|
||||
</div>
|
||||
|
||||
<!-- Добавляем кнопку "вернуться в начало" для галереи -->
|
||||
{{ partial "back-to-top.html" . }}
|
||||
|
||||
Reference in New Issue
Block a user