-
Notifications
You must be signed in to change notification settings - Fork 0
feat(blog): giscus 기반 댓글 기능 #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c1fbb8c
feat(blog): giscus 기반 댓글 기능 추가 (이슈 #57)
SimYunSup 3abe792
fix(giscus): 단일 마운트 + setConfig로 리스너 누수·테마 레이스 해소 (이슈 #57)
SimYunSup fb8cdd2
fix(giscus): lint 에러 수정 + 주석 다듬기 (이슈 #57)
SimYunSup 9e7fa0c
ci(giscus): 빌드 스텝에 VITE_GISCUS_*_ID 주입 (이슈 #57)
SimYunSup 762fbfd
fix(giscus): 기존 블로그 discussion에 number 매핑으로 연결 (이슈 #57)
SimYunSup 375f02f
refactor(giscus): 직접 구현 대신 공식 @giscus/react로 교체 (이슈 #57)
SimYunSup b8a866c
refactor(giscus): 설정값 하드코딩, CI VITE_GISCUS_* 주입 제거 (이슈 #57)
SimYunSup File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import GiscusWidget from "@giscus/react"; | ||
| import { useTheme } from "../hooks/useTheme"; | ||
| import { giscusConfig } from "../constants/giscus"; | ||
|
|
||
| interface GiscusProps { | ||
| /** 댓글을 붙일 글의 discussion 번호(= slug). */ | ||
| term: string; | ||
| } | ||
|
|
||
| /** | ||
| * giscus 댓글 위젯. | ||
| * | ||
| * 스크립트 주입·iframe 생명주기·테마/글 변경 시 setConfig 전달은 공식 | ||
| * `@giscus/react`가 맡는다. 여기서는 설정값(constants/giscus)과 현재 테마만 넘긴다. | ||
| * | ||
| * 블로그 글 slug가 곧 "블로그" 카테고리 Discussion 번호라 mapping=number로 연결한다. | ||
| */ | ||
| export function Giscus({ term }: GiscusProps) { | ||
| const { isDark } = useTheme(); | ||
|
|
||
| return ( | ||
| <GiscusWidget | ||
| repo={giscusConfig.repo} | ||
| repoId={giscusConfig.repoId} | ||
| category={giscusConfig.category} | ||
| categoryId={giscusConfig.categoryId} | ||
| mapping="number" | ||
| term={term} | ||
| reactionsEnabled="1" | ||
| emitMetadata="0" | ||
| inputPosition="bottom" | ||
| theme={isDark ? "dark" : "light"} | ||
| lang="ko" | ||
| /> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { giscusConfig } from "./giscus"; | ||
|
|
||
| describe("giscusConfig", () => { | ||
| it("repo·category 기본값을 노출한다", () => { | ||
| expect(giscusConfig.repo).toBe("DaleStudy/daleui"); | ||
| expect(giscusConfig.category).toBe("블로그"); | ||
| }); | ||
|
|
||
| it("repo-id·category-id를 함께 노출한다", () => { | ||
| expect(giscusConfig.repoId).toBeTruthy(); | ||
| expect(giscusConfig.categoryId).toBeTruthy(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // giscus 댓글 위젯 설정값. 모두 공개돼도 되는 값이라 그대로 하드코딩한다. | ||
| // 블로그 글은 DaleStudy/daleui "블로그" 카테고리 Discussion에서 오고 slug가 곧 | ||
| // discussion 번호라, mapping=number로 글마다 원본 토론에 그대로 연결한다. | ||
| export const giscusConfig = { | ||
| repo: "DaleStudy/daleui" as `${string}/${string}`, | ||
| repoId: "R_kgDOMovgOA", | ||
| category: "블로그", | ||
| categoryId: "DIC_kwDOMovgOM4CqB1o", | ||
| } as const; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
giscus component lib를 사용하시는줄 알았는데 직접 구현하셨네요 특별한 이유가 있을까요?
https://github.com/giscus/giscus-component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아, 예전에 만들었던 기억에 의존하다보니 있다는걸 몰랐네요 😅