summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEltrac <eltrac233@gmail.com>2024-11-28 23:09:27 +0800
committerEltrac <eltrac233@gmail.com>2024-11-28 23:09:27 +0800
commit7175b0c79003af98ace77129761048f153b26f7d (patch)
tree9fa28bb0d49c14dbe239212f7ac39713879c446e
parent853672e1c6621d4990e22f949a724e7162d7b43a (diff)
refactor(theme): move scripts out of individual templates
-rw-r--r--themes/yinyang/layouts/partials/scripts.html31
-rw-r--r--themes/yinyang/layouts/partials/uselibs/swup.html22
-rw-r--r--themes/yinyang/layouts/partials/uselibs/vercel-analytics.html4
3 files changed, 28 insertions, 29 deletions
diff --git a/themes/yinyang/layouts/partials/scripts.html b/themes/yinyang/layouts/partials/scripts.html
index 3764145d..3e7116fe 100644
--- a/themes/yinyang/layouts/partials/scripts.html
+++ b/themes/yinyang/layouts/partials/scripts.html
@@ -1,4 +1,29 @@
+<!-- Vercel Analytics -->
+<script>
+ window.va = window.va || function () { (window.vaq = window.vaq || []).push(arguments); };
+</script>
+<script defer src="/_vercel/insights/script.js"></script>
-<!-- 脚本 -->
-{{ partial "uselibs/vercel-analytics.html" . }}
-{{ partial "uselibs/swup.html" . }} \ No newline at end of file
+<!-- Swup -->
+<script src="https://unpkg.com/swup@4"></script>
+<script type="module">
+ import { init } from 'https://unpkg.com/@waline/client@v3/dist/waline.js';
+ const swup = new Swup();
+
+ swup.hooks.on('page:view', (visit) => {
+ if (!location.href.includes('/posts')) return;
+
+ const options = {
+ el: '#waline',
+ serverURL: 'https://waline.geedea.pro',
+ dark: 'auto',
+ pageview: true,
+ };
+
+ if (location.href.includes('localhost') || location.href.includes('127.0.0.1')) {
+ options.pageview = false;
+ }
+
+ init(options);
+ });
+</script> \ No newline at end of file
diff --git a/themes/yinyang/layouts/partials/uselibs/swup.html b/themes/yinyang/layouts/partials/uselibs/swup.html
deleted file mode 100644
index 3dde2e51..00000000
--- a/themes/yinyang/layouts/partials/uselibs/swup.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<script src="https://unpkg.com/swup@4"></script>
-<script type="module">
- import { init } from 'https://unpkg.com/@waline/client@v3/dist/waline.js';
- const swup = new Swup();
-
- swup.hooks.on('page:view', (visit) => {
- if (!location.href.includes('/posts')) return;
-
- const options = {
- el: '#waline',
- serverURL: 'https://waline.geedea.pro',
- dark: 'auto',
- pageview: true,
- };
-
- if (location.href.includes('localhost') || location.href.includes('127.0.0.1')) {
- options.pageview = false;
- }
-
- init(options);
- });
-</script>
diff --git a/themes/yinyang/layouts/partials/uselibs/vercel-analytics.html b/themes/yinyang/layouts/partials/uselibs/vercel-analytics.html
deleted file mode 100644
index 9fe89461..00000000
--- a/themes/yinyang/layouts/partials/uselibs/vercel-analytics.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<script>
- window.va = window.va || function () { (window.vaq = window.vaq || []).push(arguments); };
-</script>
-<script defer src="/_vercel/insights/script.js"></script> \ No newline at end of file