From c93cbee55737af009d2e1ae75311c71e405d83ea Mon Sep 17 00:00:00 2001 From: BY-juun Date: Wed, 29 Nov 2023 21:28:55 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20giscus=20script=20attribute=20=EC=83=81?= =?UTF-8?q?=EC=88=98=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/post/PostComments.tsx | 30 +++++++++++++++---------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/client/components/post/PostComments.tsx b/client/components/post/PostComments.tsx index 4d1a7055..bf4452f7 100644 --- a/client/components/post/PostComments.tsx +++ b/client/components/post/PostComments.tsx @@ -25,20 +25,12 @@ const Comments = () => { const scriptElem = document.createElement("script"); scriptElem.src = `${src}/client.js`; - scriptElem.setAttribute("data-repo", "BY-juun/Blog"); - scriptElem.setAttribute("data-repo-id", "MDEwOlJlcG9zaXRvcnkzODc4MTYxNjA="); - scriptElem.setAttribute("data-category", "Comments"); - scriptElem.setAttribute("data-category-id", "DIC_kwDOFx2a4M4CYB9c"); - scriptElem.setAttribute("data-mapping", "pathname"); - scriptElem.setAttribute("data-reactions-enabled", "1"); - scriptElem.setAttribute("data-emit-metadata", "0"); - scriptElem.setAttribute("data-input-position", "bottom"); + + Object.entries(SCRIPT_ATTRIBUTES).forEach(([key, value]) => { + scriptElem.setAttribute(key, value); + }); scriptElem.setAttribute("data-theme", theme); - scriptElem.setAttribute("data-lang", "ko"); - scriptElem.setAttribute("data-loading", "lazy"); - scriptElem.setAttribute("crossorigin", "anonymous"); scriptElem.async = true; - commentWrapperRef.current?.appendChild(scriptElem); return () => { @@ -56,4 +48,18 @@ const Comments = () => { return
; }; +const SCRIPT_ATTRIBUTES = { + "data-repo": "BY-juun/Blog", + "data-repo-id": "MDEwOlJlcG9zaXRvcnkzODc4MTYxNjA=", + "data-category": "Comments", + "data-category-id": "DIC_kwDOFx2a4M4CYB9c", + "data-mapping": "pathname", + "data-reactions-enabled": "1", + "data-emit-metadata": "0", + "data-input-position": "bottom", + "data-lang": "ko", + "data-loading": "lazy", + crossorigin: "anonymous", +}; + export default Comments;