@jam-comments/astro 2.5.0 → 2.6.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/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { CustomCopy } from "@jam-comments/server-utilities";
2
+
1
3
  declare global {
2
4
  interface Window {
3
5
  JamComments: {
@@ -14,6 +16,7 @@ export interface JamCommentsProps {
14
16
  baseUrl?: string;
15
17
  environment?: string;
16
18
  tz?: string;
19
+ copy?: CustomCopy;
17
20
  }
18
21
 
19
22
  export default function JamComments(args: JamCommentsProps): JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jam-comments/astro",
3
- "version": "2.5.0",
3
+ "version": "2.6.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.7.0",
42
- "@jam-comments/server-utilities": "^4.3.2",
43
- "astro": "^4.8.6",
41
+ "@astrojs/check": "^0.8.2",
42
+ "@jam-comments/server-utilities": "^5.2.0",
43
+ "astro": "^4.11.6",
44
44
  "node-fetch": "^3.3.2",
45
- "typescript": "^5.4.5"
45
+ "typescript": "^5.5.3"
46
46
  },
47
47
  "gitHead": "2b1cefb90c89a2f70099213881b09216f20e3dc2",
48
48
  "devDependencies": {
49
- "@types/node": "^20.12.12",
50
- "prettier": "^3.2.5",
51
- "prettier-plugin-astro": "^0.13.0",
52
- "vitest": "^1.6.0"
49
+ "@types/node": "^20.14.11",
50
+ "prettier": "^3.3.3",
51
+ "prettier-plugin-astro": "^0.14.1",
52
+ "vitest": "^2.0.3"
53
53
  }
54
54
  }
@@ -10,6 +10,7 @@ type Props = JamCommentsProps;
10
10
  const fetchMarkup = markupFetcher("astro", nodeFetch as any);
11
11
 
12
12
  async function fetchCommentData({
13
+ copy,
13
14
  tz = undefined,
14
15
  path = undefined,
15
16
  schema = undefined,
@@ -27,6 +28,17 @@ async function fetchCommentData({
27
28
  baseUrl,
28
29
  environment,
29
30
  tz,
31
+ copy: {
32
+ copy_confirmation_message: copy.confirmationMessage,
33
+ copy_submit_button: copy.submitButton,
34
+ copy_name_placeholder: copy.submitButton,
35
+ copy_email_placeholder: copy.submitButton,
36
+ copy_comment_placeholder: copy.submitButton,
37
+ copy_write_tab: copy.submitButton,
38
+ copy_preview_tab: copy.submitButton,
39
+ copy_auth_button: copy.submitButton,
40
+ copy_log_out_button: copy.submitButton,
41
+ },
30
42
  });
31
43
  } catch (e) {
32
44
  logError(e as string);
@@ -34,7 +46,15 @@ async function fetchCommentData({
34
46
  }
35
47
  }
36
48
 
37
- const { path, domain, baseUrl, environment, tz, schema } = Astro.props as Props;
49
+ const {
50
+ path,
51
+ domain,
52
+ baseUrl,
53
+ environment,
54
+ tz,
55
+ schema,
56
+ copy = {},
57
+ } = Astro.props as Props;
38
58
 
39
59
  const markup = await fetchCommentData({
40
60
  path: path || getCurrentPath(Astro),
@@ -43,6 +63,7 @@ const markup = await fetchCommentData({
43
63
  baseUrl,
44
64
  environment,
45
65
  tz,
66
+ copy,
46
67
  });
47
68
  ---
48
69
 
package/src/utils.test.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  import { expect, it } from "vitest";
2
2
  import { getCurrentPath } from "./utils";
3
+ import { AstroGlobal } from "astro";
3
4
 
4
5
  it("should return the current path", () => {
5
6
  const astro = {
6
7
  request: {
7
8
  url: "https://example.com/test",
8
9
  },
9
- };
10
+ } as AstroGlobal;
10
11
 
11
12
  expect(getCurrentPath(astro)).toBe("/test");
12
13
  });
@@ -16,7 +17,7 @@ it("should ignore query parameters", () => {
16
17
  request: {
17
18
  url: "https://example.com/test?query=param",
18
19
  },
19
- };
20
+ } as AstroGlobal;
20
21
 
21
22
  expect(getCurrentPath(astro)).toBe("/test");
22
23
  });
package/src/utils.ts CHANGED
@@ -1,3 +1,5 @@
1
- export function getCurrentPath(astro) {
1
+ import { AstroGlobal } from "astro";
2
+
3
+ export function getCurrentPath(astro: AstroGlobal) {
2
4
  return new URL(astro.request.url).pathname;
3
5
  }