gitalk-react 1.0.0-beta.1 → 1.0.0-beta.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/README-zh-CN.md +12 -2
- package/README.md +12 -2
- package/dist/gitalk.d.ts +1 -3
- package/dist/gitalk.js +1759 -1759
- package/dist/gitalk.umd.cjs +12 -12
- package/lib/gitalk.tsx +10 -10
- package/package.json +2 -1
package/lib/gitalk.tsx
CHANGED
|
@@ -72,14 +72,12 @@ export interface GitalkProps
|
|
|
72
72
|
* The unique id of the page.
|
|
73
73
|
* Length must less than 50.
|
|
74
74
|
*
|
|
75
|
-
* @default location.
|
|
75
|
+
* @default location.pathname
|
|
76
76
|
*/
|
|
77
77
|
id?: string;
|
|
78
78
|
/**
|
|
79
79
|
* The issue ID of the page.
|
|
80
80
|
* If the number attribute is not defined, issue will be located using id.
|
|
81
|
-
*
|
|
82
|
-
* @default -1
|
|
83
81
|
*/
|
|
84
82
|
number?: number;
|
|
85
83
|
/**
|
|
@@ -201,8 +199,8 @@ const Gitalk: React.FC<GitalkProps> = (props) => {
|
|
|
201
199
|
owner,
|
|
202
200
|
repo,
|
|
203
201
|
admin,
|
|
204
|
-
id: propsIssueId = location.
|
|
205
|
-
number:
|
|
202
|
+
id: propsIssueId = location.pathname,
|
|
203
|
+
number: propsIssueNumber,
|
|
206
204
|
labels: issueBaseLabels = DEFAULT_LABELS,
|
|
207
205
|
title: issueTitle = document.title,
|
|
208
206
|
body: issueBody = location.href +
|
|
@@ -230,6 +228,8 @@ const Gitalk: React.FC<GitalkProps> = (props) => {
|
|
|
230
228
|
...restProps
|
|
231
229
|
} = props;
|
|
232
230
|
const issueId = propsIssueId.slice(0, 50);
|
|
231
|
+
const issueNumber =
|
|
232
|
+
propsIssueNumber && propsIssueNumber > 0 ? propsIssueNumber : undefined;
|
|
233
233
|
const commentsPerPage =
|
|
234
234
|
propsPerPage > 100 ? 100 : propsPerPage < 0 ? 10 : propsPerPage;
|
|
235
235
|
const defaultUser = propsDefaultUser
|
|
@@ -481,7 +481,7 @@ const Gitalk: React.FC<GitalkProps> = (props) => {
|
|
|
481
481
|
loading: getCommentsLoading,
|
|
482
482
|
} = useRequest(
|
|
483
483
|
async (): Promise<CommentType[]> => {
|
|
484
|
-
const { number:
|
|
484
|
+
const { number: currentIssueNumber } = issue as IssueType;
|
|
485
485
|
const from = (commentsPage - 1) * commentsPerPage + 1;
|
|
486
486
|
const to = commentsPage * commentsPerPage;
|
|
487
487
|
|
|
@@ -495,7 +495,7 @@ const Gitalk: React.FC<GitalkProps> = (props) => {
|
|
|
495
495
|
await octokit.graphql(query, {
|
|
496
496
|
owner,
|
|
497
497
|
repo,
|
|
498
|
-
id:
|
|
498
|
+
id: currentIssueNumber,
|
|
499
499
|
pageSize: commentsPerPage,
|
|
500
500
|
...(commentsCursor ? { cursor: commentsCursor } : {}),
|
|
501
501
|
});
|
|
@@ -550,7 +550,7 @@ const Gitalk: React.FC<GitalkProps> = (props) => {
|
|
|
550
550
|
{
|
|
551
551
|
owner,
|
|
552
552
|
repo,
|
|
553
|
-
issue_number:
|
|
553
|
+
issue_number: currentIssueNumber,
|
|
554
554
|
page: commentsPage,
|
|
555
555
|
per_page: commentsPerPage,
|
|
556
556
|
headers: {
|
|
@@ -608,14 +608,14 @@ const Gitalk: React.FC<GitalkProps> = (props) => {
|
|
|
608
608
|
run: runCreateIssueComment,
|
|
609
609
|
} = useRequest(
|
|
610
610
|
async (): Promise<CommentType[]> => {
|
|
611
|
-
const { number:
|
|
611
|
+
const { number: currentIssueNumber } = issue as IssueType;
|
|
612
612
|
|
|
613
613
|
const createIssueCommentRes = await octokit.request(
|
|
614
614
|
"POST /repos/{owner}/{repo}/issues/{issue_number}/comments",
|
|
615
615
|
{
|
|
616
616
|
owner,
|
|
617
617
|
repo,
|
|
618
|
-
issue_number:
|
|
618
|
+
issue_number: currentIssueNumber,
|
|
619
619
|
body: inputComment,
|
|
620
620
|
headers: {
|
|
621
621
|
accept: "application/vnd.github.v3.full+json",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gitalk-react",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "LolipopJ",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"./gitalk-light.css": "./dist/gitalk-light.css",
|
|
30
30
|
"./gitalk-dark.css": "./dist/gitalk-dark.css"
|
|
31
31
|
},
|
|
32
|
+
"types": "./dist/gitalk.d.ts",
|
|
32
33
|
"scripts": {
|
|
33
34
|
"dev": "vite",
|
|
34
35
|
"build": "npm run build:ts && npm run build:scss",
|