Skip to content

Commit 7d1a72c

Browse files
committed
feat: Utterances 댓글 기능을 위한 코드 수정 및 리팩토링
1 parent f981c76 commit 7d1a72c

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

.vscode/workspace.code-snippets

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
{
22
"Create Post": {
33
"prefix": ["!meta"],
4-
"body": ["---", "title: $1", "createdAt: $2", "category: $3", "description: $6", "---"],
4+
"body": [
5+
"---",
6+
"title: $1",
7+
"createdAt: $2",
8+
"category: $3",
9+
"description: $6",
10+
"comment: true",
11+
"---",
12+
],
513
},
614
}

src/components/PostComment/PostComment.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<script setup lang="ts">
22
import { onMounted, onBeforeUnmount, watch, ref, nextTick, toRef, type Ref } from "vue";
33
4+
const COMMENT_REPOSITORY = "toothlessdev/toothlessdev.github.io";
5+
46
const props = defineProps<{
57
theme: string;
68
}>();
@@ -9,8 +11,8 @@ const containerRef = ref<HTMLDivElement | null>(null);
911
1012
function mountUtterances(theme: string) {
1113
const container = containerRef.value;
12-
if (!container) return;
1314
15+
if (!container) return;
1416
if (container.querySelector("iframe.utterances-frame")) return;
1517
1618
const script = document.createElement("script");
@@ -19,7 +21,7 @@ function mountUtterances(theme: string) {
1921
script.async = true;
2022
script.crossOrigin = "anonymous";
2123
22-
script.setAttribute("repo", "toothlessdev/toothlessdev-comments");
24+
script.setAttribute("repo", COMMENT_REPOSITORY);
2325
script.setAttribute("issue-term", "pathname");
2426
script.setAttribute("label", "blog-comment");
2527
script.setAttribute("theme", theme);
@@ -38,12 +40,12 @@ onMounted(async () => {
3840
mountUtterances(props.theme);
3941
});
4042
41-
watch(toRef(props, "theme"), (t) => {
43+
watch(toRef(props, "theme"), (theme) => {
4244
if (!containerRef.value?.querySelector("iframe.utterances-frame")) {
43-
mountUtterances(t);
45+
mountUtterances(theme);
4446
return;
4547
}
46-
setUtterancesTheme(t);
48+
setUtterancesTheme(theme);
4749
});
4850
4951
onBeforeUnmount(() => {

0 commit comments

Comments
 (0)