From e780356b9a1adf73ae8f27d7f4ea1444eba02b4b Mon Sep 17 00:00:00 2001 From: HEIGE-PCloud Date: Thu, 28 Mar 2024 20:47:40 +0000 Subject: [PATCH] feat: only load tablesort if needed --- layouts/_default/single.html | 1 + layouts/partials/assets.html | 2 +- layouts/posts/single.html | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 39529e520..b510d69f9 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,6 +1,7 @@ {{- define "title" }}{{ .Title }} - {{ .Site.Title }}{{ end -}} {{- define "content" -}} + {{- .Page.Scratch.SetInMap "this" "tablesort" true -}} {{- $params := .Scratch.Get "params" -}}
{{- /* Title */ -}} diff --git a/layouts/partials/assets.html b/layouts/partials/assets.html index af4a25abc..d07043991 100644 --- a/layouts/partials/assets.html +++ b/layouts/partials/assets.html @@ -25,7 +25,7 @@ {{- end -}} {{- /* tablesort */ -}} -{{- if $params.table | and $params.table.sort -}} +{{- if $params.table | and $params.table.sort | and (.Scratch.Get "this").tablesort -}} {{- $source := $cdn.tablesort | default "lib/tablesort/tablesort.min.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}} {{- $config = dict "sort" true | dict "table" | merge $config -}} diff --git a/layouts/posts/single.html b/layouts/posts/single.html index 8d81371e2..16b8e53af 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -1,6 +1,7 @@ {{- define "title" }}{{ .Title }} - {{ .Site.Title }}{{ end -}} {{- define "content" -}} + {{- .Page.Scratch.SetInMap "this" "tablesort" true -}} {{- $params := .Scratch.Get "params" -}} {{- $toc := $params.toc -}} {{- if eq $toc true -}}