From 5ad98eeadb0cb5af66f12b3d547de05994c61c9f Mon Sep 17 00:00:00 2001 From: FarseaSH Date: Wed, 26 Jun 2024 22:09:50 +0800 Subject: [PATCH] IMPROVEMENT: give a jsonp api to return the number of moments and fix incorrect count for a certain section. --- layouts/_default/list.js.js | 4 ++++ layouts/_default/list.json.json | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 layouts/_default/list.js.js diff --git a/layouts/_default/list.js.js b/layouts/_default/list.js.js new file mode 100644 index 0000000..8c4a03d --- /dev/null +++ b/layouts/_default/list.js.js @@ -0,0 +1,4 @@ +function showMomentCount() { {{ $a := where $.Site.RegularPages "Section" .Section}}{{ if .IsHome }}{{ $a = $.Site.RegularPages }}{{ end }} + document.getElementById("momentCount").innerHTML = {{ len $a }}; +} +showMomentCount() \ No newline at end of file diff --git a/layouts/_default/list.json.json b/layouts/_default/list.json.json index a0a2820..fc2f96d 100644 --- a/layouts/_default/list.json.json +++ b/layouts/_default/list.json.json @@ -1,4 +1,4 @@ -{ +{ {{ $a := where $.Site.RegularPages "Section" .Section}}{{ if .IsHome }}{{ $a = $.Site.RegularPages }}{{ end }} "sectionName": "{{ default "index" .Section }}", - "momentCount": {{ len .Site.RegularPages }} + "momentCount": {{ len $a }} } \ No newline at end of file