import './index.css' import {AppBskyFeedDefs, BskyAgent} from '@atproto/api' import {h, render} from 'preact' import logo from '../assets/logo.svg' import {Container} from './container' import {Link} from './link' import {Post} from './post' import {getRkey} from './utils' const root = document.getElementById('app') if (!root) throw new Error('No root element') const searchParams = new URLSearchParams(window.location.search) const agent = new BskyAgent({ service: 'https://public.api.bsky.app', }) const uri = searchParams.get('uri') if (!uri) { throw new Error('No uri in query string') } agent .getPostThread({ uri, depth: 0, parentHeight: 0, }) .then(({data}) => { if (!AppBskyFeedDefs.isThreadViewPost(data.thread)) { throw new Error('Expected a ThreadViewPost') } const pwiOptOut = !!data.thread.post.author.labels?.find( label => label.val === '!no-unauthenticated', ) if (pwiOptOut) { render(, root) } else { render(, root) } }) .catch(err => { console.error(err) render(, root) }) function PwiOptOut({thread}: {thread: AppBskyFeedDefs.ThreadViewPost}) { const href = `/profile/${thread.post.author.did}/post/${getRkey(thread.post)}` return ( The author of this post has requested their posts not be displayed on external sites. View on Bluesky ) } function ErrorMessage() { return ( Post not found, it may have been deleted. ) }
The author of this post has requested their posts not be displayed on external sites.
Post not found, it may have been deleted.