@xingwangzhe/stalux 1.41.2 → 1.41.3

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.41.2",
3
+ "version": "1.41.3",
4
4
  "description": "A powerful, modern Astro blog theme — use as template or install as plugin",
5
5
  "keywords": [
6
6
  "astro",
@@ -5,6 +5,7 @@ import { type CollectionEntry, getCollection } from "astro:content";
5
5
  import { getSiteData } from "@utils/config-utils";
6
6
  import { formatInTimeZone, parseDate, toTimestamp, zonedCalendarParts } from "@utils/dayjs";
7
7
  import { createTranslator } from "@utils/i18n";
8
+ import { toMachineDateTime } from "@utils/semantic-time";
8
9
 
9
10
  interface Props {
10
11
  posts?: CollectionEntry<"posts">[];
@@ -81,7 +82,10 @@ const archiveYears = [...archivesByYearMonth.entries()]
81
82
  <li class="stalux-archive-post-item">
82
83
  <time
83
84
  class="stalux-archive-post-date"
84
- datetime={post.data.date}
85
+ datetime={toMachineDateTime(
86
+ post.data.date,
87
+ timezone,
88
+ )}
85
89
  >
86
90
  {formatInTimeZone(
87
91
  parseDate(post.data.date, timezone),
@@ -2,6 +2,7 @@
2
2
  import { getCollection } from "astro:content";
3
3
  import { getSiteData } from "@utils/config-utils";
4
4
  import { createTranslator } from "@utils/i18n";
5
+ import { toMachineDateTime } from "@utils/semantic-time";
5
6
 
6
7
  interface Props {
7
8
  showStats?: boolean;
@@ -13,6 +14,11 @@ const configEntries = await getCollection("config");
13
14
  const siteConfig = getSiteData(configEntries);
14
15
  const { t } = createTranslator(siteConfig.lang || "zh-CN");
15
16
  const { showStats = true, wordCount, buildtime } = Astro.props;
17
+ // buildtime 会被浏览器端 new Date(dataset) 解析:裸串会按访客本地时区解释,
18
+ // 不同时区访客算出的运行时长不同。这里统一转成带站点时区偏移的机器时间。
19
+ const machineBuildtime = buildtime
20
+ ? toMachineDateTime(buildtime, siteConfig.timezone || "Asia/Shanghai")
21
+ : undefined;
16
22
  ---
17
23
 
18
24
  {showStats && (
@@ -34,10 +40,10 @@ const { showStats = true, wordCount, buildtime } = Astro.props;
34
40
  </p>
35
41
  )}
36
42
 
37
- {buildtime && (
43
+ {machineBuildtime && (
38
44
  <div
39
45
  class="stalux-stats-site-build-time stalux-u-text-center"
40
- data-stalux-buildtime={buildtime}
46
+ data-stalux-buildtime={machineBuildtime}
41
47
  data-stalux-runtime-format={t("footer.runtimeFormat")}
42
48
  >
43
49
  <span>