1
0
Fork 0
mirror of https://github.com/dillonzq/LoveIt.git synced 2025-04-26 21:56:19 +02:00

feat(resource): refactor resources structure ()

This commit is contained in:
Dillon 2025-03-03 09:14:03 +08:00 committed by GitHub
parent b2c9e1091d
commit 4c5fdf7856
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
78 changed files with 24 additions and 2 deletions
assets/lib
fontawesome-free/webfonts
katex/fonts
lightgallery/fonts
layouts/partials
package.json
static/lib/images

View file

Before

(image error) Size: 12 KiB

After

(image error) Size: 12 KiB

View file

@ -45,6 +45,12 @@
{{- if $params.lightgallery -}}
{{- $source := $cdn.lightgalleryCSS | default "lib/lightgallery/css/lightgallery-bundle.min.css" -}}
{{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/style.html" -}}
{{- if not $cdn.lightgalleryCSS -}}
{{- (resources.Get "lib/lightgallery/images/loading.gif").Publish -}}
{{- range resources.Match "lib/lightgallery/fonts/*" -}}
{{- .Publish -}}
{{- end -}}
{{- end -}}
{{- $source := $cdn.lightgalleryJS | default "lib/lightgallery/lightgallery.min.js" -}}
{{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}
{{- $source := $cdn.lightgalleryThumbnailJS | default "lib/lightgallery/plugins/thumbnail/lg-thumbnail.min.js" -}}
@ -52,7 +58,6 @@
{{- $source := $cdn.lightgalleryZoomJS | default "lib/lightgallery/plugins/zoom/lg-zoom.min.js" -}}
{{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}
{{- $config = dict "lightgallery" true | merge $config -}}
{{- $_ := (resources.Get "lib/lightgallery/images/loading.gif").RelPermalink -}}
{{- end -}}
{{- /* clipboard.js */ -}}
@ -85,6 +90,11 @@
{{- if $math.enable -}}
{{- $source := $cdn.katexCSS | default "lib/katex/katex.min.css" -}}
{{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/style.html" -}}
{{- if not $cdn.katexCSS -}}
{{- range resources.Match "lib/katex/fonts/*" -}}
{{- .Publish -}}
{{- end -}}
{{- end -}}
{{- $source := $cdn.katexJS | default "lib/katex/katex.min.js" -}}
{{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}
{{- $source := $cdn.katexAutoRenderJS | default "lib/katex/contrib/auto-render.min.js" -}}
@ -120,7 +130,6 @@
{{- if (.Scratch.Get "this").mermaid -}}
{{- $source := $cdn.mermaidJS | default "lib/mermaid/mermaid.min.js" -}}
{{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}
{{- $_ := (resources.Get "lib/mermaid/mermaid.min.js.map").RelPermalink -}}
{{- end -}}
{{- /* ECharts */ -}}

View file

@ -39,6 +39,11 @@
{{- $source := $cdn.fontawesomeFreeCSS | default "lib/fontawesome-free/css/all.min.css" -}}
{{- $options := dict "Source" $source "Fingerprint" $fingerprint "Preload" true -}}
{{- partial "plugin/style.html" $options -}}
{{- if not $cdn.fontawesomeFreeCSS -}}
{{- range resources.Match "lib/fontawesome-free/webfonts/*" -}}
{{- .Publish -}}
{{- end -}}
{{- end -}}
{{- /* Animate.css */ -}}
{{- $source := $cdn.animateCSS | default "lib/animate/animate.min.css" -}}

View file

@ -8,6 +8,9 @@
{{- $integrity := .Integrity -}}
{{- if (urls.Parse $src).Host | not -}}
{{- $resource := resources.Get $src -}}
{{- with printf `%v.map` $src | resources.Get -}}
{{- .Publish -}}
{{- end -}}
{{- with .Template -}}
{{- $resource = $resource | resources.ExecuteAsTemplate . $.Context -}}
{{- end -}}

View file

@ -6,6 +6,9 @@
{{- $resource := 0 -}}
{{- if $href | and (not (urls.Parse $href).Host) -}}
{{- $resource = resources.Get $href -}}
{{- with printf `%v.map` $href | resources.Get -}}
{{- .Publish -}}
{{- end -}}
{{- end -}}
{{- with .Content -}}
{{- $resource = resources.FromString $.Path . -}}

View file

@ -19,8 +19,10 @@
"compile": "npx babel src/js --out-file assets/js/theme.js",
"compile-lunr-segmentit": "browserify src/lib/lunr/lunr.segmentit.js -o assets/lib/lunr/lunr.segmentit.js -t babelify --presets @babel/preset-env",
"hugo": "hugo --source exampleSite --buildDrafts --gc",
"hugo-development": "hugo --source exampleSite --buildDrafts --gc --minify --environment development",
"hugo-production": "hugo --source exampleSite --gc --minify --environment production",
"hugo-server": "hugo server --source exampleSite --buildDrafts --disableFastRender",
"hugo-server-development": "hugo server --source exampleSite --buildDrafts --disableFastRender --environment development",
"hugo-server-production": "hugo server --source exampleSite --minify --disableFastRender --environment production",
"htmlproofer": "htmlproofer exampleSite/public --disable-external true --ignore-missing-alt true",
"copy-resources": "cp -rf exampleSite/resources ."

Binary file not shown.

Before

(image error) Size: 4.1 KiB