@jam-comments/astro 0.0.6 → 1.0.0-beta.1
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 +8 -4
- package/src/index.astro +12 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jam-comments/astro",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
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.",
|
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
"homepage": "https://jamcomments.com",
|
|
10
10
|
"repository": "github:alexmacarthur/jam-comments-javascript",
|
|
11
11
|
"scripts": {
|
|
12
|
-
"build": "echo 'No build step here...'"
|
|
12
|
+
"build": "echo 'No build step here...'",
|
|
13
|
+
"format": "prettier --write src"
|
|
13
14
|
},
|
|
14
15
|
"files": [
|
|
15
|
-
"src",
|
|
16
|
+
"src",
|
|
16
17
|
"index.d.ts"
|
|
17
18
|
],
|
|
18
19
|
"keywords": [
|
|
@@ -31,5 +32,8 @@
|
|
|
31
32
|
"astro": "^1.6.12",
|
|
32
33
|
"node-fetch": "^3.3.0"
|
|
33
34
|
},
|
|
34
|
-
"gitHead": "2b1cefb90c89a2f70099213881b09216f20e3dc2"
|
|
35
|
+
"gitHead": "2b1cefb90c89a2f70099213881b09216f20e3dc2",
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"prettier": "^2.8.3"
|
|
38
|
+
}
|
|
35
39
|
}
|
package/src/index.astro
CHANGED
|
@@ -7,8 +7,16 @@ export interface Props {
|
|
|
7
7
|
path: string;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
declare global {
|
|
11
|
+
interface Window {
|
|
12
|
+
JamComments: {
|
|
13
|
+
initialize: () => void;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
10
18
|
const CLIENT_SCRIPT_URL =
|
|
11
|
-
"https://unpkg.com/@jam-comments/client@
|
|
19
|
+
"https://unpkg.com/@jam-comments/client@2.0.0-beta.2/dist/index.umd.js";
|
|
12
20
|
const fetchMarkup = markupFetcher("astro", nodeFetch as any);
|
|
13
21
|
const fetchCommentData = async (pagePath: string) => {
|
|
14
22
|
try {
|
|
@@ -17,7 +25,7 @@ const fetchCommentData = async (pagePath: string) => {
|
|
|
17
25
|
domain: import.meta.env.JAM_COMMENTS_DOMAIN,
|
|
18
26
|
apiKey: import.meta.env.JAM_COMMENTS_API_KEY,
|
|
19
27
|
baseUrl: import.meta.env.JAM_COMMENTS_BASE_URL,
|
|
20
|
-
environment: import.meta.env.JAM_COMMENTS_ENVIRONMENT
|
|
28
|
+
environment: import.meta.env.JAM_COMMENTS_ENVIRONMENT,
|
|
21
29
|
});
|
|
22
30
|
} catch (e) {
|
|
23
31
|
logError(e as string);
|
|
@@ -29,10 +37,9 @@ const { path } = Astro.props;
|
|
|
29
37
|
const markup = await fetchCommentData(path);
|
|
30
38
|
---
|
|
31
39
|
|
|
32
|
-
<div set:html={markup}
|
|
40
|
+
<div set:html={markup} />
|
|
33
41
|
|
|
34
42
|
<script src={CLIENT_SCRIPT_URL}></script>
|
|
35
43
|
<script>
|
|
36
|
-
|
|
37
|
-
(JamComments as any).initialize(root);
|
|
44
|
+
window.JamComments.initialize();
|
|
38
45
|
</script>
|