mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
⚡ Chore: optimize .Resources variable acquisition in function resources.html
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
{{- if .Title | and .Text -}}
|
||||
<figure>
|
||||
{{- dict "Src" .Destination "Alt" .Text "Caption" .Text "Title" .Title "Linked" true "Resources" .Page.Resources "Responsive" true | partial "plugin/image.html" -}}
|
||||
{{- dict "Src" .Destination "Alt" .Text "Caption" .Text "Title" .Title "Linked" true "Responsive" true | partial "plugin/image.html" -}}
|
||||
<figcaption class="image-caption">
|
||||
{{- .Text | safeHTML -}}
|
||||
</figcaption>
|
||||
</figure>
|
||||
{{- else -}}
|
||||
{{- $linked := (eq (.Page.Scratch.Get "params").lightgallery "force") | or (ne .Title "") -}}
|
||||
{{- dict "Src" .Destination "Alt" .Text "Title" .Title "Linked" $linked "Resources" .Page.Resources "Responsive" true | partial "plugin/image.html" -}}
|
||||
{{- dict "Src" .Destination "Alt" .Text "Title" .Title "Linked" $linked "Responsive" true | partial "plugin/image.html" -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{{- $destination := .Destination -}}
|
||||
{{- with dict "Path" $destination "Resources" .Page.Resources | partial "function/resource.html" -}}
|
||||
{{- with dict "Path" $destination | partial "function/resource.html" -}}
|
||||
{{- $destination = .RelPermalink -}}
|
||||
{{- end -}}
|
||||
{{- $options := dict "Destination" $destination "Title" .Title "Content" .Text "ExternalIcon" .Page.Site.Params.externalIcon -}}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
{{ range $index, $friend := .Site.Data.friends }}
|
||||
<a class="friend-link" title="{{ $friend.description }}" href="{{ $friend.url | safeURL }}" rel="external noopener noreferrer" target="_blank">
|
||||
{{ if $friend.avatar }}
|
||||
{{- dict "Src" $friend.avatar "Alt" $friend.nickname "Class" "friend-avatar" "Resources" $.Resources | partial "plugin/image.html" -}}
|
||||
{{- dict "Src" $friend.avatar "Alt" $friend.nickname "Class" "friend-avatar" | partial "plugin/image.html" -}}
|
||||
{{ else }}
|
||||
<svg class="friend-avatar" aria-hidden="true">
|
||||
<use xlink:href="#icon-{{ add 1 $index }}"></use>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
{{ range $index, $friend := .Site.Data.friends }}
|
||||
<a class="friend-link" title="{{ $friend.description }}" href="{{ $friend.url | safeURL }}" rel="external noopener noreferrer" target="_blank">
|
||||
{{ if $friend.avatar }}
|
||||
{{- dict "Src" $friend.avatar "Alt" $friend.nickname "Class" "friend-avatar" "Resources" $.Resources | partial "plugin/image.html" -}}
|
||||
{{- dict "Src" $friend.avatar "Alt" $friend.nickname "Class" "friend-avatar" | partial "plugin/image.html" -}}
|
||||
{{ else }}
|
||||
<svg class="friend-avatar" aria-hidden="true">
|
||||
<use xlink:href="#icon-{{ add 1 $index }}"></use>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
{{- $Resources := .Resources | default page.Resources -}}
|
||||
{{- $resource := 0 -}}
|
||||
{{- $url := urls.Parse .Path -}}
|
||||
{{- if not $url.Host | and $url.Path | and (strings.HasSuffix $url.Path "/" | not) -}}
|
||||
{{- if .Resources -}}
|
||||
{{- with .Resources.GetMatch $url.Path -}}
|
||||
{{- if $Resources -}}
|
||||
{{- with $Resources.GetMatch $url.Path -}}
|
||||
{{- $resource = . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
"description": {{ . | safeHTML }},
|
||||
{{- end -}}
|
||||
{{- $image := .Site.Params.seo.image -}}
|
||||
{{- with dict "Path" $image "Resources" .Resources | partial "function/resource.html" -}}
|
||||
{{- with dict "Path" $image | partial "function/resource.html" -}}
|
||||
"image": {
|
||||
"@type": "ImageObject",
|
||||
"url": "{{ .Permalink }}",
|
||||
@@ -55,7 +55,7 @@
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- with .Site.Params.seo.thumbnailUrl -}}
|
||||
{{- with dict "Path" . "Resources" $.Resources | partial "function/resource.html" -}}
|
||||
{{- with dict "Path" . | partial "function/resource.html" -}}
|
||||
"thumbnailUrl": "{{ .Permalink }}",
|
||||
{{- else -}}
|
||||
"thumbnailUrl": "{{ . | absURL }}",
|
||||
@@ -104,7 +104,7 @@
|
||||
"image": [
|
||||
{{- range $index, $value := . -}}
|
||||
{{- if gt $index 0 }},{{ end -}}
|
||||
{{- with dict "Path" $value "Resources" $.Resources | partial "function/resource.html" -}}
|
||||
{{- with dict "Path" $value | partial "function/resource.html" -}}
|
||||
{
|
||||
"@type": "ImageObject",
|
||||
"url": "{{ .Permalink }}",
|
||||
@@ -142,7 +142,7 @@
|
||||
"@type": "Organization",
|
||||
"name": {{ $publisher.name | safeHTML }}
|
||||
{{- $logo := $publisher.logoUrl -}}
|
||||
{{- with dict "Path" $logo "Resources" .Resources | partial "function/resource.html" -}}
|
||||
{{- with dict "Path" $logo | partial "function/resource.html" -}}
|
||||
,"logo": {
|
||||
"@type": "ImageObject",
|
||||
"url": "{{ .Permalink }}",
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
{{- with T (printf "single.reward.%v" $way) -}}{{ $way = . }}{{- end -}}
|
||||
{{- if $image -}}
|
||||
<div>
|
||||
{{- dict "Src" $image "Alt" (printf "%v %v" $author $way) "Resources" $.Resources | partial "plugin/image.html" -}}
|
||||
{{- dict "Src" $image "Alt" (printf "%v %v" $author $way) | partial "plugin/image.html" -}}
|
||||
<span{{ if $reward.animation }} data-animation{{ end }}>{{ $way }}</span>
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
{{- "<![CDATA[" | safeHTML -}}
|
||||
{{- with $image -}}
|
||||
<div class="featured-image">
|
||||
{{- dict "Src" . "Title" $.Page.Description "Alt" $.Page.Title "Resources" $.Page.Resources "Loading" "eager" "Referrerpolicy" "no-referrer" | partial "plugin/image.html" -}}
|
||||
{{- dict "Src" . "Title" $.Page.Description "Alt" $.Page.Title "Loading" "eager" "Referrerpolicy" "no-referrer" | partial "plugin/image.html" -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{- $content := .Page.Description -}}
|
||||
|
||||
@@ -142,7 +142,7 @@
|
||||
{{- end -}}
|
||||
{{- with $image -}}
|
||||
<div class="featured-image">
|
||||
{{- dict "Src" . "Title" $.Description "Resources" $.Resources | partial "plugin/image.html" -}}
|
||||
{{- dict "Src" . "Title" $.Description | partial "plugin/image.html" -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
{{- $options = cond $caption true false | dict "Linked" | merge $options -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $options = dict "Resources" .Page.Resources "Responsive" true | merge $options -}}
|
||||
{{- $options = dict "Responsive" true | merge $options -}}
|
||||
|
||||
{{- with $caption -}}
|
||||
<figure{{ with cond $.IsNamedParams ($.Get "class") "" }} class="{{ . }}"{{ end }}>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{{- $destination := cond .IsNamedParams (.Get "href") (.Get 0) -}}
|
||||
{{- with dict "Path" $destination "Resources" .Page.Resources | partial "function/resource.html" -}}
|
||||
{{- with dict "Path" $destination | partial "function/resource.html" -}}
|
||||
{{- $destination = .RelPermalink -}}
|
||||
{{- end -}}
|
||||
{{- $options := dict "Destination" $destination -}}
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
{{- $theme = .Get "theme" | default $theme -}}
|
||||
{{- if .Get "url" -}}
|
||||
{{- $url := .Get "url" -}}
|
||||
{{- with dict "Path" $url "Resources" .Page.Resources | partial "function/resource.html" -}}
|
||||
{{- with dict "Path" $url | partial "function/resource.html" -}}
|
||||
{{- $url = .RelPermalink -}}
|
||||
{{- end -}}
|
||||
{{- $cover := .Get "cover" -}}
|
||||
{{- with dict "Path" $cover "Resources" .Page.Resources | partial "function/resource.html" -}}
|
||||
{{- with dict "Path" $cover | partial "function/resource.html" -}}
|
||||
{{- $cover = .RelPermalink -}}
|
||||
{{- end -}}
|
||||
<meting-js url="{{ $url }}" name="{{ .Get `name` }}" artist="{{ .Get `artist` }}" cover="{{ $cover }}" theme="{{ $theme }}"
|
||||
|
||||
Reference in New Issue
Block a user