
Język 🇵🇱 Polski
Dokumentacja
Pierwsze kroki
Użycie
Konfiguracja
Add Comments to Your SolidJS App
To oficjalna biblioteka SolidJS dla FastComments.
Osadź w swojej aplikacji SolidJS widżety do komentowania na żywo, czatu i recenzji.
Repozytorium
Demo na żywo 
Wypróbuj każdy widżet na żywo pod adresem https://fastcomments.com/commenting-system-for-solidjs.
Użycie 
import { FastCommentsCommentWidget } from 'fastcomments-solidjs';
export default function App() {
return <FastCommentsCommentWidget tenantId="demo" urlId="some-page-id" />;
}
Reagowanie na zmiany konfiguracji (imperatywny uchwyt) 
Solid nie śledzi automatycznie głębokich mutacji w dowolnych obiektach, więc zmiany konfiguracji po pierwszym renderze muszą być zastosowane jawnie. Każdy widget akceptuje apiRef, który zwraca uchwyt; wywołaj handle.update(partial) z createEffect, aby napędzać reaktywność:
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() is safe to call at any time:
- Przed załadowaniem skryptu: partial jest odłożony i zastosowany podczas inicjalizacji.
- Podczas asynchronicznej inicjalizacji (reviews-summary, user-activity-feed): partial jest umieszczony w kolejce i zastosowany, gdy callback się zakończy.
- Po inicjalizacji: jest przekazywany bezpośrednio do metody
.update()działającego widgetu.
Imperative handle API
interface WidgetHandle<Config> {
getInstance: () => WidgetInstance | null; // ostatnia aktywna instancja (lub null przed zamontowaniem)
onInstance: (cb: (instance: WidgetInstance) => void) => void; // wywoływane, gdy instancja jest gotowa
update: (partial: Partial<Config>) => void; // scal i zastosuj konfigurację
}
Use getInstance() for imperative actions that aren't covered by .update(), e.g. openProfile:
const openProfile = () =>
(handle?.getInstance() as { openProfile?: (o: { userId: string }) => void } | null)
?.openProfile?.({ userId: 'demo' });
Komponenty 
Każdy widget z fastcomments-react jest dostępny pod tą samą nazwą:
| Komponent | Typ uchwytu | Ładowany embed |
|---|---|---|
FastCommentsCommentWidget |
FastCommentsCommentWidgetHandle |
Flagowy widget komentarzy na żywo |
FastCommentsCommentCountWidget |
FastCommentsCommentCountWidgetHandle |
Wbudowana plakietka z liczbą komentarzy |
FastCommentsLiveChatWidget |
FastCommentsLiveChatWidgetHandle |
Strumieniowy widget czatu na żywo |
FastCommentsCollabChatWidget |
FastCommentsCollabChatWidgetHandle |
Współpracujący czat powiązany z tekstem |
FastCommentsImageChatWidget |
FastCommentsImageChatWidgetHandle |
Komentarze obrazów oparte na regionach |
FastCommentsRecentCommentsWidget |
FastCommentsRecentCommentsWidgetHandle |
Kanał najnowszych komentarzy |
FastCommentsRecentDiscussionsWidget |
FastCommentsRecentDiscussionsWidgetHandle |
Kanał najnowszych dyskusji |
FastCommentsReviewsSummaryWidget |
FastCommentsReviewsSummaryWidgetHandle |
Podsumowanie ocen gwiazdkowych |
FastCommentsTopPagesWidget |
FastCommentsTopPagesWidgetHandle |
Ranking stron z największą liczbą komentarzy |
FastCommentsUserActivityFeedWidget |
FastCommentsUserActivityFeedWidgetHandle |
Oś czasu aktywności użytkownika |
Widgety, które montują się w istniejącym elemencie
FastCommentsCollabChatWidget i FastCommentsImageChatWidget montują się w elemencie dostarczonym przez wywołującego. Przekaż funkcję targetRef, która zwraca element po zamontowaniu:
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}
/>
</>
);
}
Regiony
Przekaż region="eu", aby kierować ruch widgetu przez klaster UE.
Potrzebujesz pomocy?
Jeśli napotkasz jakiekolwiek problemy lub masz pytania dotyczące biblioteki SolidJS, prosimy:
Współtworzenie
Wkłady są mile widziane! Prosimy odwiedzić repozytorium na GitHubie po wytyczne dotyczące współtworzenia.