UNPKG

react-bluesky-embed

Version:

React Bluesky Embed allows you to embed post threads, profiles, and comments in your React application when using Next.js, Create React App, Vite, and more.

1 lines 970 B
import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{Suspense}from"react";import{getPostThread}from"./api/index.js";import{EmbeddedPostThread,PostThreadNotFound,PostThreadSkeleton}from"./bluesky-theme/components.js";const PostThreadContent=async({params,theme="light",config,onError,hidePost})=>{let error;const postThread=params?await getPostThread(params,config).catch(err=>{if(onError){error=onError(err)}else{console.error(err);error=err}}):undefined;if(!postThread){const NotFound=PostThreadNotFound;return /*#__PURE__*/_jsx(NotFound,{theme:theme,error:error})}return /*#__PURE__*/_jsx(_Fragment,{children:/*#__PURE__*/_jsx(EmbeddedPostThread,{theme:theme,postThread:postThread,hidePost:hidePost},JSON.stringify(params))})};export const PostThread=({theme,fallback=/*#__PURE__*/_jsx(PostThreadSkeleton,{theme:theme}),...props})=>/*#__PURE__*/_jsx(Suspense,{fallback:fallback,children:/*#__PURE__*/_jsx(PostThreadContent,{theme:theme,...props})});