@jam-comments/astro 2.7.0 → 2.8.0
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 +6 -6
- package/src/component.astro +17 -10
- package/src/config.ts +5 -3
- package/src/env.d.ts +1 -0
- package/src/utils.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jam-comments/astro",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"author": "Alex MacArthur <alex@macarthur.me> (https://macarthur.me)",
|
|
5
5
|
"license": "GPL-2.0",
|
|
6
6
|
"description": "Easily add performant, SEO-friendly comments to your Astro blog with JamComments.",
|
|
@@ -38,17 +38,17 @@
|
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@astrojs/check": "^0.
|
|
42
|
-
"@jam-comments/server-utilities": "^5.
|
|
43
|
-
"astro": "^4.
|
|
41
|
+
"@astrojs/check": "^0.9.3",
|
|
42
|
+
"@jam-comments/server-utilities": "^5.10.0",
|
|
43
|
+
"astro": "^4.15.1",
|
|
44
44
|
"node-fetch": "^3.3.2",
|
|
45
45
|
"typescript": "^5.5.4"
|
|
46
46
|
},
|
|
47
47
|
"gitHead": "2b1cefb90c89a2f70099213881b09216f20e3dc2",
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@types/node": "^
|
|
49
|
+
"@types/node": "^22.5.1",
|
|
50
50
|
"prettier": "^3.3.3",
|
|
51
51
|
"prettier-plugin-astro": "^0.14.1",
|
|
52
|
-
"vitest": "^2.0.
|
|
52
|
+
"vitest": "^2.0.5"
|
|
53
53
|
}
|
|
54
54
|
}
|
package/src/component.astro
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
import type { JamCommentsProps } from "..";
|
|
3
3
|
import { fetchCommentData, getCurrentPath } from "./utils";
|
|
4
|
+
import { Store } from "@jam-comments/server-utilities";
|
|
4
5
|
|
|
5
6
|
type Props = JamCommentsProps;
|
|
6
7
|
|
|
@@ -15,16 +16,22 @@ const {
|
|
|
15
16
|
copy = {},
|
|
16
17
|
} = Astro.props as Props;
|
|
17
18
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
const store = new Store();
|
|
20
|
+
const pagePath = path || getCurrentPath(Astro);
|
|
21
|
+
const cachedMarkup = store.get(pagePath) || store.emptyMarkup;
|
|
22
|
+
|
|
23
|
+
const markup =
|
|
24
|
+
cachedMarkup ||
|
|
25
|
+
(await fetchCommentData({
|
|
26
|
+
tz,
|
|
27
|
+
copy,
|
|
28
|
+
path: pagePath,
|
|
29
|
+
schema,
|
|
30
|
+
domain,
|
|
31
|
+
baseUrl,
|
|
32
|
+
environment,
|
|
33
|
+
dateFormat,
|
|
34
|
+
}));
|
|
28
35
|
---
|
|
29
36
|
|
|
30
37
|
<div set:html={markup} />
|
package/src/config.ts
CHANGED
|
@@ -7,6 +7,8 @@ interface PluginArgs {
|
|
|
7
7
|
environment?: string;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
globalThis.jamCommentsStore = new Map<string, string>();
|
|
11
|
+
|
|
10
12
|
export function jamComments({
|
|
11
13
|
domain,
|
|
12
14
|
apiKey,
|
|
@@ -16,8 +18,8 @@ export function jamComments({
|
|
|
16
18
|
return {
|
|
17
19
|
name: "jamcomments",
|
|
18
20
|
hooks: {
|
|
19
|
-
"astro:build:start": () => {
|
|
20
|
-
|
|
21
|
+
"astro:build:start": async () => {
|
|
22
|
+
globalThis.jamCommentsStore = await fetchAll(
|
|
21
23
|
{
|
|
22
24
|
tz: timezone,
|
|
23
25
|
domain,
|
|
@@ -30,7 +32,7 @@ export function jamComments({
|
|
|
30
32
|
},
|
|
31
33
|
|
|
32
34
|
"astro:build:done": () => {
|
|
33
|
-
|
|
35
|
+
globalThis.jamCommentsStore.clear();
|
|
34
36
|
},
|
|
35
37
|
},
|
|
36
38
|
};
|
package/src/env.d.ts
CHANGED
package/src/utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import nodeFetch from "node-fetch";
|
|
1
|
+
// import nodeFetch from "node-fetch";
|
|
2
2
|
import { AstroGlobal } from "astro";
|
|
3
3
|
import { JamCommentsProps } from "..";
|
|
4
4
|
import { logError, markupFetcher } from "@jam-comments/server-utilities";
|
|
@@ -13,7 +13,7 @@ export function removeFalseyValues<T>(obj: T): Partial<T> {
|
|
|
13
13
|
return Object.fromEntries(filteredItems) as Partial<T>;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
const fetchMarkup = markupFetcher("astro"
|
|
16
|
+
const fetchMarkup = markupFetcher("astro");
|
|
17
17
|
|
|
18
18
|
export async function fetchCommentData(
|
|
19
19
|
{
|