
์ธ์ด ๐ฐ๐ท ํ๊ตญ์ด
๋ฌธ์
์์ํ๊ธฐ
์ฌ์ฉ๋ฒ
์ค์
Add Comments to Your SolidJS App
์ด๊ฒ์ FastComments์ ๊ณต์ SolidJS ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๋๋ค.
์ค์๊ฐ ๋๊ธ, ์ฑํ ๋ฐ ๋ฆฌ๋ทฐ ์์ ฏ์ SolidJS ์ฑ์ ์๋ฒ ๋ํ์ธ์.
์ ์ฅ์
๋ผ์ด๋ธ ๋ฐ๋ชจ 
๋ชจ๋ ์์ ฏ์ ์ค์๊ฐ์ผ๋ก ์ฒดํํด ๋ณด์ธ์ https://fastcomments.com/commenting-system-for-solidjs.
์ฌ์ฉ๋ฒ 
import { FastCommentsCommentWidget } from 'fastcomments-solidjs';
export default function App() {
return <FastCommentsCommentWidget tenantId="demo" urlId="some-page-id" />;
}
์ค์ ๋ณ๊ฒฝ์ ๋ฐ์ํ๊ธฐ (๋ช
๋ นํ ํธ๋ค) 
Solid์ ์์ ๊ฐ์ฒด์ ๊น์ ๋ณ๊ฒฝ์ ์๋์ผ๋ก ์ถ์ ํ์ง ์์ผ๋ฏ๋ก
์ฒซ ๋ ๋ ์ดํ์ config ๋ณ๊ฒฝ์ ๋ช
์์ ์ผ๋ก ํธ์ํด์ผ ํฉ๋๋ค. ๋ชจ๋ ์์ ฏ์
ํธ๋ค์ ๋ฐํํ๋ apiRef๋ฅผ ํ์ฉํฉ๋๋ค; ๋ฐ์์ฑ์ ๊ตฌ๋ํ๋ ค๋ฉด createEffect์์
handle.update(partial)๋ฅผ ํธ์ถํ์ธ์:
import { createEffect, createSignal } from 'solid-js';
import { FastCommentsCommentWidget, type FastCommentsCommentWidgetHandle } from 'fastcomments-solidjs';
export default function Paginated() {
const [page, setPage] = createSignal(0);
let handle: FastCommentsCommentWidgetHandle | undefined;
createEffect(() => handle?.update({ urlId: `product-${page()}` }));
return (
<>
<button onClick={() => setPage(page() + 1)}>next</button>
<FastCommentsCommentWidget
apiRef={(h) => (handle = h)}
tenantId="demo"
urlId={`product-${page()}`}
/>
</>
);
}
update()๋ ์ธ์ ๋ ์ง ํธ์ถํด๋ ์์ ํฉ๋๋ค:
- Before the script has loaded: the partial is stashed and applied at init.
- During an async init (reviews-summary, user-activity-feed): the partial is queued and applied when the callback resolves.
- After init: it forwards straight to the live widget's
.update()method.
๋ช ๋ นํ ํธ๋ค API
interface WidgetHandle<Config> {
getInstance: () => WidgetInstance | null; // ์ต์ ๋ผ์ด๋ธ ์ธ์คํด์ค(๋๋ ๋ง์ดํธ ์ ์๋ null)
onInstance: (cb: (instance: WidgetInstance) => void) => void; // ์ธ์คํด์ค๊ฐ ์ค๋น๋๋ฉด ํ ๋ฒ ํธ์ถ๋จ
update: (partial: Partial<Config>) => void; // ๊ตฌ์ฑ ๋ณํฉ ๋ฐ ํธ์
}
.update()๋ก ๋ค๋ฃจ์ด์ง์ง ์๋ ๋ช
๋ นํ ๋์์๋ getInstance()๋ฅผ ์ฌ์ฉํ์ธ์. ์: openProfile:
const openProfile = () =>
(handle?.getInstance() as { openProfile?: (o: { userId: string }) => void } | null)
?.openProfile?.({ userId: 'demo' });
์ปดํฌ๋ํธ 
fastcomments-react์ ๋ชจ๋ ์์ ฏ์ ๋์ผํ ์ด๋ฆ์ผ๋ก ์ฌ์ฉ ๊ฐ๋ฅํฉ๋๋ค:
| ์ปดํฌ๋ํธ | ํธ๋ค ํ์ | ๋ก๋๋ ์๋ฒ ๋ |
|---|---|---|
FastCommentsCommentWidget |
FastCommentsCommentWidgetHandle |
์ฃผ๋ ฅ ์ค์๊ฐ ๋๊ธ ์์ ฏ |
FastCommentsCommentCountWidget |
FastCommentsCommentCountWidgetHandle |
์ธ๋ผ์ธ ๋๊ธ ์ ๋ฐฐ์ง |
FastCommentsLiveChatWidget |
FastCommentsLiveChatWidgetHandle |
์คํธ๋ฆฌ๋ฐ ๋ผ์ด๋ธ ์ฑํ ์์ ฏ |
FastCommentsCollabChatWidget |
FastCommentsCollabChatWidgetHandle |
ํ ์คํธ ์ต์ปค ๊ธฐ๋ฐ ํ์ ์ฑํ |
FastCommentsImageChatWidget |
FastCommentsImageChatWidgetHandle |
์์ญ ๊ธฐ๋ฐ ์ด๋ฏธ์ง ๋๊ธ |
FastCommentsRecentCommentsWidget |
FastCommentsRecentCommentsWidgetHandle |
์ต๊ทผ ๋๊ธ ํผ๋ |
FastCommentsRecentDiscussionsWidget |
FastCommentsRecentDiscussionsWidgetHandle |
์ต๊ทผ ํ ๋ก ํผ๋ |
FastCommentsReviewsSummaryWidget |
FastCommentsReviewsSummaryWidgetHandle |
๋ณ์ ์์ฝ |
FastCommentsTopPagesWidget |
FastCommentsTopPagesWidgetHandle |
๋๊ธ ์ต๋ค ํ์ด์ง ์์ |
FastCommentsUserActivityFeedWidget |
FastCommentsUserActivityFeedWidgetHandle |
์ฌ์ฉ์๋ณ ํ๋ ํ์๋ผ์ธ |
๊ธฐ์กด ์์์ ์ฒจ๋ถ๋๋ ์์ ฏ
FastCommentsCollabChatWidget์ FastCommentsImageChatWidget์ ํธ์ถ์๊ฐ ์ ๊ณตํ ์์์ ๋ง์ดํธ๋ฉ๋๋ค. ๋ง์ดํธ๋ ํ ์์๋ฅผ ๋ฐํํ๋ targetRef ์ ๊ทผ์๋ฅผ ์ ๋ฌํ์ธ์:
import { FastCommentsImageChatWidget } from 'fastcomments-solidjs';
export default function ImageChat() {
let img: HTMLImageElement | undefined;
return (
<>
<img ref={img} src="/screenshot.png" alt="" />
<FastCommentsImageChatWidget
tenantId="demo"
urlId="my-image"
targetRef={() => img}
/>
</>
);
}
๋ฆฌ์
region="eu"๋ฅผ ์ ๋ฌํ๋ฉด ์์ ฏ ํธ๋ํฝ์ด EU ํด๋ฌ์คํฐ๋ฅผ ํตํด ๋ผ์ฐํ
๋ฉ๋๋ค.
๋์์ด ํ์ํ์ ๊ฐ์?
SolidJS ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๊ด๋ จํ์ฌ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๊ฑฐ๋ ์ง๋ฌธ์ด ์์ผ์๋ฉด, ๋ค์์ ์ด์ฉํ์ธ์:
๊ธฐ์ฌํ๊ธฐ
๊ธฐ์ฌ๋ ํ์ํฉ๋๋ค! ๊ธฐ์ฌ ์ง์นจ์ GitHub ๋ฆฌํฌ์งํ ๋ฆฌ๋ฅผ ๋ฐฉ๋ฌธํ์ธ์.