summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBigCoke233 <hi@guhub.cn>2026-01-16 23:59:31 +0800
committerBigCoke233 <hi@guhub.cn>2026-01-16 23:59:31 +0800
commitbcd509c540632b6524a8dd87a4613e64ed0402f6 (patch)
treed55ed80119c7a72a07d7eed40c7750f63b22d42a
parent9fab8272ca7d94841c3543eab8a4c1e91dd76b85 (diff)
perf: load aplayer resources only when needed
-rw-r--r--content/posts/weekly/31.md1
-rw-r--r--content/posts/weekly/40.md1
-rw-r--r--layouts/_partials/head/css.html6
-rw-r--r--layouts/_partials/scripts/aplayer-js.html2
4 files changed, 8 insertions, 2 deletions
diff --git a/content/posts/weekly/31.md b/content/posts/weekly/31.md
index 917ea1ce..c45bf92d 100644
--- a/content/posts/weekly/31.md
+++ b/content/posts/weekly/31.md
@@ -18,6 +18,7 @@ endnotes:
- 封面图上的摄像头,像不像停在电线杆上的鸟呢?
aliases:
- /posts/weekly/31
+hasAplayer: true
---
diff --git a/content/posts/weekly/40.md b/content/posts/weekly/40.md
index 9794bc81..8c72358d 100644
--- a/content/posts/weekly/40.md
+++ b/content/posts/weekly/40.md
@@ -17,6 +17,7 @@ endnotes:
- 封面图自摄,设备为 iPhone 15 Pro
aliases:
- /posts/weekly/40
+hasAplayer: true
---
diff --git a/layouts/_partials/head/css.html b/layouts/_partials/head/css.html
index f7fa9a9c..37e0002a 100644
--- a/layouts/_partials/head/css.html
+++ b/layouts/_partials/head/css.html
@@ -1,6 +1,8 @@
<!-- Aplayer -->
-{{ with resources.Get "css/aplayer.css" }}
-<style>{{ .Content | safeCSS }}</style>
+{{ if and (not .IsHome) .Params.hasAplayer }}
+ {{ with resources.Get "css/aplayer.css" }}
+ <style>{{ .Content | safeCSS }}</style>
+ {{ end }}
{{ end }}
<!-- Pagefind -->
diff --git a/layouts/_partials/scripts/aplayer-js.html b/layouts/_partials/scripts/aplayer-js.html
index e777b0c9..2aa3db3d 100644
--- a/layouts/_partials/scripts/aplayer-js.html
+++ b/layouts/_partials/scripts/aplayer-js.html
@@ -1,3 +1,4 @@
+{{ if and (not .IsHome) .Params.hasAplayer }}
<script>
document.addEventListener("DOMContentLoaded", function () {
const lazyPlayers = document.querySelectorAll(".lazy-aplayer");
@@ -43,3 +44,4 @@ document.addEventListener("DOMContentLoaded", function () {
lazyPlayers.forEach(player => observer.observe(player));
});
</script>
+{{ end }}