mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
feat(shortcodes): add store flags for aplayer, music, mapbox, and fixit-encryptor
This commit is contained in:
@@ -156,7 +156,7 @@ FixIt theme assets partial
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Mapbox GL */ -}}
|
||||
{{- if .HasShortcode "mapbox" -}}
|
||||
{{- if .Store.Get "hasMapbox" -}}
|
||||
{{- $source := $cdn.mapboxGLCSS | default "lib/mapbox-gl/mapbox-gl.css" -}}
|
||||
{{- dict "Source" $source "Minify" true "Fingerprint" $fingerprint "Preload" true | dict "Page" . "Data" | partial "store/style.html" -}}
|
||||
{{- $source = $cdn.mapboxGLJS | default "lib/mapbox-gl/mapbox-gl.js" -}}
|
||||
@@ -166,7 +166,7 @@ FixIt theme assets partial
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Music */ -}}
|
||||
{{- if (.HasShortcode "aplayer") | or (.HasShortcode "music") -}}
|
||||
{{- if (.Store.Get "hasAplayer") | or (.Store.Get "hasMusic") -}}
|
||||
{{- /* APlayer */ -}}
|
||||
{{- $source := $cdn.aplayerCSS | default "lib/aplayer/APlayer.min.css" -}}
|
||||
{{- dict "Source" $source "Fingerprint" $fingerprint "Preload" true | dict "Page" . "Data" | partial "store/style.html" -}}
|
||||
@@ -175,14 +175,14 @@ FixIt theme assets partial
|
||||
{{- $source := $cdn.aplayerJS | default "lib/aplayer/APlayer.min.js" -}}
|
||||
{{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}}
|
||||
|
||||
{{- if .HasShortcode "aplayer" -}}
|
||||
{{- if .Store.Get "hasAplayer" -}}
|
||||
{{- $options := dict "targetPath" "js/lib/aplayer.min.js" "minify" hugo.IsProduction -}}
|
||||
{{- if not hugo.IsProduction -}}
|
||||
{{- $options = dict "sourceMap" "external" | merge $options -}}
|
||||
{{- end -}}
|
||||
{{- dict "Source" (resources.Get "js/lib/aplayer.js") "Build" $options "Fingerprint" $fingerprint "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}}
|
||||
{{- end -}}
|
||||
{{- if .HasShortcode "music" -}}
|
||||
{{- if .Store.Get "hasMusic" -}}
|
||||
{{- /* MetingJS */ -}}
|
||||
{{- $source := $cdn.metingJS | default "lib/meting/Meting.min.js" -}}
|
||||
{{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}}
|
||||
@@ -232,7 +232,7 @@ FixIt theme assets partial
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Content Decryption */ -}}
|
||||
{{- $encryptPartial := .HasShortcode "fixit-encryptor" -}}
|
||||
{{- $encryptPartial := .Store.Get "hasEncryptor" -}}
|
||||
{{- if $params.password | or $encryptPartial -}}
|
||||
{{- $cryptoCoreJS := $cdn.cryptoCoreJS | default "lib/crypto-js/core.js" -}}
|
||||
{{- $cryptoEncBase64JS := $cdn.cryptoEncBase64JS | default "lib/crypto-js/enc-base64.js" -}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{- hugo.Store.Set "version" "v0.4.3" -}}
|
||||
{{- hugo.Store.Set "version" "v0.4.4-20260304032604-ba63d67a" -}}
|
||||
{{- .Store.Set "this" dict -}}
|
||||
|
||||
{{- partial "init/detection-env.html" . -}}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
{{- $audio = replace $audio "}" "}," | printf "[%s]" -}}
|
||||
{{- $audio = replace $audio ",]" "]" -}}
|
||||
<div class="aplayer-shortcode" data-audio="{{ $audio }}" data-options="{{ $options }}"></div>
|
||||
{{- .Page.Store.Set "hasAplayer" true -}}
|
||||
{{- else -}}
|
||||
{{- errorf "Only named params is supported: %s" .Position -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
{{- $content := .Inner | .Page.RenderString -}}
|
||||
{{- /* Content Encryption */ -}}
|
||||
{{- dict "Content" $content "Password" $password "Message" $message "IsPartial" true "Page" .Page | partial "plugin/fixit-encryptor.html" -}}
|
||||
{{- .Page.Store.Set "hasEncryptor" true -}}
|
||||
{{- else -}}
|
||||
{{- .Inner -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -33,4 +33,4 @@
|
||||
|
||||
{{- $attrs := printf `style="width: %v; height: %v;"` $width $height -}}
|
||||
<div class="mapbox" data-options="{{ $options | jsonify }}" {{ $attrs | safeHTMLAttr }}></div>
|
||||
{{- /* EOF */ -}}
|
||||
{{- .Page.Store.Set "hasMapbox" true -}}
|
||||
|
||||
@@ -47,3 +47,4 @@
|
||||
{{- else -}}
|
||||
<meting-js server="{{ .Get 0 }}" type="{{ .Get 1 }}" id="{{ .Get 2 }}" theme="{{ $theme }}"></meting-js>
|
||||
{{- end -}}
|
||||
{{- .Page.Store.Set "hasMusic" true -}}
|
||||
|
||||
Reference in New Issue
Block a user