Skip to content

Commit

Permalink
feat: only load tablesort if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
HEIGE-PCloud committed Mar 28, 2024
1 parent 5c8f429 commit e780356
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions 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" -}}
<div class="page single special print:!tw-w-full print:!tw-max-w-none print:!tw-m-0 print:!tw-p-0">
{{- /* Title */ -}}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/assets.html
Expand Up @@ -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 -}}
Expand Down
1 change: 1 addition & 0 deletions 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 -}}
Expand Down

0 comments on commit e780356

Please sign in to comment.