Skip to content

Commit

Permalink
🚚 Feat: migarte params.cacheRemoteImages to params.page.cacheRemoteIm…
Browse files Browse the repository at this point in the history
…ages (#362)
  • Loading branch information
Lruihao committed Dec 30, 2023
1 parent 07756a8 commit de5fd0c
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 18 deletions.
20 changes: 9 additions & 11 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,15 @@ enableEmoji = true
scale = true
# whether to add FullscreenControl
fullscreen = true
# FixIt 0.3.0 | NEW [Experimental] cache remote images locally, see: https://github.com/hugo-fixit/FixIt/pull/362
[params.page.cacheRemoteImages]
enable = false
# replace remote image url with local image url (place in public/images/remote/)
replace = false
# FixIt 0.3.0 | NEW Related content config (https://gohugo.io/content-management/related/)
[params.page.related]
enable = false
count = 5
# FixIt 0.2.17 | NEW Donate (Sponsor) settings
[params.page.reward]
enable = false
Expand Down Expand Up @@ -916,11 +925,6 @@ enableEmoji = true
name = ""
logoUrl = ""

# FixIt 0.3.0 | NEW Related content config (https://gohugo.io/content-management/related/)
[params.page.related]
enable = false
count = 5

# TypeIt config
[params.typeit]
# typing speed between each step (measured in milliseconds)
Expand Down Expand Up @@ -1073,12 +1077,6 @@ enableEmoji = true
# "corner-indicator", "fill-left", "flash", "flat-top", "loading-bar", "mac-osx", "material", "minimal"]
theme = "minimal"

# FixIt 0.3.0 | NEW [Experimental] cache remote images locally, see: https://github.com/hugo-fixit/FixIt/pull/362
[params.cacheRemoteImages]
enable = false
# replace remote image url with local image url
replace = false

# FixIt 0.2.17 | NEW Define custom file paths
# Create your custom files in site directory `layouts/partials/custom` and uncomment needed files below
[params.customFilePath]
Expand Down
4 changes: 2 additions & 2 deletions layouts/_default/_markup/render-image.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{{- if .Title | and .Text -}}
<figure>
{{- dict "Src" .Destination "Alt" .Text "Caption" .Text "Title" .Title "Linked" true "Resources" .Page.Resources "Params" .Page.Params "Responsive" true | partial "plugin/image.html" -}}
{{- dict "Src" .Destination "Alt" .Text "Caption" .Text "Title" .Title "Linked" true "Resources" .Page.Resources "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 "Params" .Page.Params "Responsive" true | partial "plugin/image.html" -}}
{{- dict "Src" .Destination "Alt" .Text "Title" .Title "Linked" $linked "Resources" .Page.Resources "Responsive" true | partial "plugin/image.html" -}}
{{- end -}}
2 changes: 1 addition & 1 deletion layouts/friends/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h1 class="single-title animate__animated animate__pulse animate__faster">{{- .T
{{ 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 "Params" $.Params | partial "plugin/image.html" -}}
{{- dict "Src" $friend.avatar "Alt" $friend.nickname "Class" "friend-avatar" "Resources" $.Resources | partial "plugin/image.html" -}}
{{ else }}
<svg class="friend-avatar" aria-hidden="true">
<use xlink:href="#icon-{{ add 1 $index }}"></use>
Expand Down
2 changes: 1 addition & 1 deletion layouts/page/friends.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h1 class="single-title animate__animated animate__pulse animate__faster">{{- .T
{{ 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 "Params" $.Params | partial "plugin/image.html" -}}
{{- dict "Src" $friend.avatar "Alt" $friend.nickname "Class" "friend-avatar" "Resources" $.Resources | partial "plugin/image.html" -}}
{{ else }}
<svg class="friend-avatar" aria-hidden="true">
<use xlink:href="#icon-{{ add 1 $index }}"></use>
Expand Down
3 changes: 2 additions & 1 deletion layouts/partials/plugin/image.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{{- $params := page.Scratch.Get "params" -}}
{{- $class := .Class | default "" -}}
{{- $style := "" -}}
{{- $loading := .Loading | default "lazy" -}}
{{- $onload := "" -}}
{{- $onerror := "" -}}
{{- $cacheRemoteImages := (.Params.cacheRemoteImages | default dict) | merge site.Params.cacheRemoteImages -}}
{{- $cacheRemoteImages := $params.cacheRemoteImages -}}
{{- $suffixList := slice ".jpeg" ".jpg" ".png" ".gif" ".bmp" ".tif" ".tiff" ".webp" -}}

{{- /* handle for default size image */ -}}
Expand Down
2 changes: 1 addition & 1 deletion layouts/shortcodes/image.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{{- $options = cond $caption true false | dict "Linked" | merge $options -}}
{{- end -}}

{{- $options = dict "Resources" .Page.Resources "Params" .Page.Params "Responsive" true | merge $options -}}
{{- $options = dict "Resources" .Page.Resources "Responsive" true | merge $options -}}

{{- with $caption -}}
<figure{{ with cond $.IsNamedParams ($.Get "class") "" }} class="{{ . }}"{{ end }}>
Expand Down

0 comments on commit de5fd0c

Please sign in to comment.