@xingwangzhe/stalux 1.22.5 → 1.22.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xingwangzhe/stalux",
3
- "version": "1.22.5",
3
+ "version": "1.22.7",
4
4
  "description": "A powerful, modern Astro blog theme — use as template or install as plugin",
5
5
  "keywords": [
6
6
  "astro",
@@ -75,7 +75,6 @@
75
75
  "prepare": "git config core.hooksPath scripts/git-hooks"
76
76
  },
77
77
  "dependencies": {
78
- "@astrojs/partytown": "^2.1.7",
79
78
  "@astrojs/rss": "^4.0.19",
80
79
  "@astrojs/sitemap": "^3.7.3",
81
80
  "@expressive-code/plugin-line-numbers": "^0.44.1",
@@ -91,7 +90,7 @@
91
90
  "astro-seo": "^1.1.0",
92
91
  "astro-typewriter": "^1.2.0",
93
92
  "badge-maker": "^6.0.0",
94
- "js-yaml": "^5.2.3",
93
+ "js-yaml": "^5.3.0",
95
94
  "pagefind": "^1.5.2",
96
95
  "photoswipe": "^5.4.4",
97
96
  "satteri": "^0.9.5",
@@ -100,7 +99,7 @@
100
99
  "temml": "^0.13.4"
101
100
  },
102
101
  "devDependencies": {
103
- "astro": "^7.2.1",
102
+ "astro": "^7.2.2",
104
103
  "knip": "^6.32.2",
105
104
  "license-checker-rseidelsohn": "5.0.1",
106
105
  "oxfmt": "^0.63.0",
@@ -108,6 +107,6 @@
108
107
  "typescript": "^7.0.2"
109
108
  },
110
109
  "peerDependencies": {
111
- "astro": "7.2.0"
110
+ "astro": "7.2.1"
112
111
  }
113
112
  }
@@ -6,11 +6,20 @@ const headConfig = getHeadData(configEntries);
6
6
  const id = headConfig?.bingClarityId;
7
7
  ---
8
8
 
9
- {
10
- id && (
11
- <>
12
- <script type="text/partytown" set:html={`window.clarity = window.clarity || function(){ (window.clarity.q = window.clarity.q || []).push(arguments); };`}></script>
13
- <script type="text/partytown" src={`https://www.clarity.ms/tag/${id}`}></script>
14
- </>
15
- )
16
- }
9
+ <script is:inline data-astro-rerun define:vars={{ id }}>
10
+ // 防止重复初始化
11
+ const load = () => {
12
+ if (!id || document.getElementById("stalux-clarity-script") || window.clarity) return;
13
+ (function (c, l, a, r, i, t, y) {
14
+ c[a] = c[a] || function () { (c[a].q = c[a].q || []).push(arguments); };
15
+ t = l.createElement(r);
16
+ t.id = "stalux-clarity-script";
17
+ t.async = 1;
18
+ t.src = "https://www.clarity.ms/tag/" + i;
19
+ y = l.getElementsByTagName(r)[0];
20
+ y.parentNode.insertBefore(t, y);
21
+ })(window, document, "clarity", "script", id);
22
+ };
23
+ if ("requestIdleCallback" in window) requestIdleCallback(load, { timeout: 4000 });
24
+ else window.addEventListener("load", () => setTimeout(load, 0), { once: true });
25
+ </script>
@@ -4,32 +4,31 @@ import { getHeadData } from "@utils/config-utils";
4
4
  const configEntries = await getCollection("config");
5
5
  const headConfig = getHeadData(configEntries);
6
6
  const gaID = headConfig?.googleAnalyticsId;
7
- const gaBootstrap = gaID
8
- ? `window.dataLayer = window.dataLayer || [];
9
- window.gtag = function gtag() { dataLayer.push(arguments); };
10
- gtag("js", new Date());
11
- gtag("config", ${JSON.stringify(gaID)}, { send_page_view: false });
12
- gtag("event", "page_view", { page_title: document.title, page_location: location.href });`
13
- : "";
14
7
  ---
15
8
 
16
- {
17
- gaID && (
18
- <>
19
- <script
20
- type="text/partytown"
21
- src={`https://www.googletagmanager.com/gtag/js?id=${gaID}`}></script>
22
- <script type="text/partytown" set:html={gaBootstrap}></script>
23
- <script is:inline>
24
- let lastPath = window.location.pathname;
9
+ <script is:inline define:vars={{ gaID }}>
10
+ (() => {
11
+ const load = () => {
12
+ if (window.__staluxAnalyticsLoaded) return;
13
+ window.__staluxAnalyticsLoaded = true;
14
+ const script = document.createElement("script");
15
+ script.async = true;
16
+ script.src = `https://www.googletagmanager.com/gtag/js?id=${gaID}`;
17
+ document.head.appendChild(script);
18
+ window.dataLayer = window.dataLayer || [];
19
+ window.gtag = window.gtag || function () {
20
+ window.dataLayer.push(arguments);
21
+ };
22
+ window.gtag("js", new Date());
23
+ window.gtag("config", gaID);
24
+ if (!window.__gtagListenerAdded) {
25
25
  document.addEventListener("astro:page-load", () => {
26
- const path = window.location.pathname;
27
- if (path !== lastPath) {
28
- lastPath = path;
29
- window.gtag?.("event", "page_view", { page_path: path });
30
- }
26
+ window.gtag("event", "page_view", { page_path: window.location.pathname });
31
27
  });
32
- </script>
33
- </>
34
- )
35
- }
28
+ window.__gtagListenerAdded = true;
29
+ }
30
+ };
31
+ if ("requestIdleCallback" in window) requestIdleCallback(load, { timeout: 3000 });
32
+ else window.addEventListener("load", () => setTimeout(load, 0), { once: true });
33
+ })();
34
+ </script>
@@ -9,6 +9,8 @@ const umamiURL = umamiConfig?.url;
9
9
  ---
10
10
 
11
11
  <script
12
- type="text/partytown"
12
+ defer
13
13
  src={umamiURL}
14
- data-website-id={umamiID}></script>
14
+ data-website-id={umamiID}
15
+ type="text/javascript"
16
+ data-astro-rerun></script>