From 6cef8c40d2d26cf440510f73f5d074b766e8e6e8 Mon Sep 17 00:00:00 2001 From: HEIGE-PCloud Date: Thu, 28 Mar 2024 20:23:22 +0000 Subject: [PATCH] feat: load sharer only when needed --- layouts/partials/assets.html | 2 +- layouts/partials/plugin/share.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/partials/assets.html b/layouts/partials/assets.html index 3a29eb045..af4a25abc 100644 --- a/layouts/partials/assets.html +++ b/layouts/partials/assets.html @@ -72,7 +72,7 @@ {{- end -}} {{- /* Sharer.js */ -}} -{{- if $params.share.enable -}} +{{- if $params.share.enable | and (.Scratch.Get "this").sharer -}} {{- $source := $cdn.sharerJS | default "lib/sharer/sharer.min.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}} {{- $config = dict "sharerjs" true | merge $config -}} diff --git a/layouts/partials/plugin/share.html b/layouts/partials/plugin/share.html index 92f3a2af5..245a70309 100644 --- a/layouts/partials/plugin/share.html +++ b/layouts/partials/plugin/share.html @@ -1,5 +1,5 @@ {{- $share := (.Scratch.Get "params").share | default dict -}} - +{{- .Page.Scratch.SetInMap "this" "sharer" true -}} {{- if $share.enable -}} {{- /* 001: Twitter */ -}} {{- if $share.Twitter -}}