diff --git a/src/components/comment/Comments.astro b/src/components/comment/Comments.astro index df8fbad..b5cec85 100644 --- a/src/components/comment/Comments.astro +++ b/src/components/comment/Comments.astro @@ -10,7 +10,7 @@ interface Props { const { commentKey, title } = Astro.props; const config = await getConfig(); -const comments = config != null ? await loadComments(commentKey, 0, config) : null; +const comments = config != null ? await loadComments(commentKey, title, 0, config) : null; ---
diff --git a/src/components/comment/artalk.ts b/src/components/comment/artalk.ts index 0cf21a2..0e5e270 100644 --- a/src/components/comment/artalk.ts +++ b/src/components/comment/artalk.ts @@ -30,14 +30,25 @@ export const getConfig = async (): Promise => { return data != null ? (data as CommentConfig) : data; }; -export const loadComments = async (key: string, offset: number, config: CommentConfig): Promise => { - const query = querystring.stringify({ +export const loadComments = async ( + key: string, + title: string | null, + offset: number, + config: CommentConfig, +): Promise => { + let params: Record = { limit: config.frontend_conf.pagination.pageSize, offset: offset, flat_mode: false, page_key: key, site_name: options.title, - }); + }; + if (title !== null) { + params = { ...params, title: title }; + } + const query = querystring.stringify(params); + + console.log(query); const data = await fetch(urlJoin(server, `/api/v2/comments?${query}`)) .then((response) => response.json()) .catch((e) => { diff --git a/src/pages/comments/list.ts b/src/pages/comments/list.ts index 46e6b71..a7b3dba 100644 --- a/src/pages/comments/list.ts +++ b/src/pages/comments/list.ts @@ -19,7 +19,7 @@ export const GET: APIRoute = async ({ url }) => { return new Response(''); } - const comments = await loadComments(key, Number(offset), config); + const comments = await loadComments(key, null, Number(offset), config); if (comments === null) { return new Response(''); }