import DOMPurify from 'dompurify' import { Filter, nip19 } from 'nostr-tools' import { useRef, useState } from 'react' import { useParams } from 'react-router-dom' import { BlogCard } from '../components/BlogCard' import { ProfileSection } from '../components/ProfileSection' import { RelayController } from '../controllers' import { useDidMount } from '../hooks' import '../styles/comments.css' import '../styles/downloads.css' import '../styles/innerPage.css' import '../styles/post.css' import '../styles/reactions.css' import '../styles/styles.css' import '../styles/tabs.css' import '../styles/tags.css' import '../styles/write.css' import { ModDetails } from '../types' import { extractModData } from '../utils' import { formatDate } from 'date-fns' export const InnerModPage = () => { const { nevent } = useParams() const [modData, setModData] = useState() useDidMount(async () => { if (nevent) { const decoded = nip19.decode<'nevent'>(nevent as `nevent1${string}`) const eventId = decoded.data.id const kind = decoded.data.kind const author = decoded.data.author const relays = decoded.data.relays || [] const filter: Filter = { ids: [eventId] } if (kind) filter.kinds = [kind] if (author) filter.authors = [author] RelayController.getInstance() .fetchEvent(filter, relays) .then((event) => { console.log('event :>> ', event) if (event) { const extracted = extractModData(event) setModData(extracted) } }) .catch((err) => { console.log('err :>> ', err) }) } }) const postBodyRef = useRef(null) const viewFullPostBtnRef = useRef(null) const oldDownloadListRef = useRef(null) const viewFullPost = () => { if (postBodyRef.current && viewFullPostBtnRef.current) { postBodyRef.current.style.maxHeight = 'unset' postBodyRef.current.style.padding = 'unset' viewFullPostBtnRef.current.style.display = 'none' } } const handleViewOldLinks = () => { if (oldDownloadListRef.current) { // Toggle styles if (oldDownloadListRef.current.style.height === '0px') { // Enable styles oldDownloadListRef.current.style.padding = '' oldDownloadListRef.current.style.height = '' oldDownloadListRef.current.style.border = '' } else { // Disable styles oldDownloadListRef.current.style.padding = '0' oldDownloadListRef.current.style.height = '0' oldDownloadListRef.current.style.border = 'unset' } } } if (!modData) return null return (

{modData.title}

View

{modData.screenshotsUrls.map((url, index) => ( {`ScreenShot-${index}`} ))}
{modData.tags.map((tag, index) => ( {tag} ))}

420

69k

4.2k

69

{formatDate( (modData.published_at !== -1 ? modData.published_at : modData.edited_at) * 1000, 'dd/m/yyyy' )}

{formatDate(modData.edited_at * 1000, 'dd/m/yyyy')}

{modData.site}

Mod Download

{modData.downloadUrls.length > 0 && (
)} {modData.downloadUrls.length > 1 && ( <>
{modData.downloadUrls .slice(1) .map((download, index) => ( ))}
)}

Creator's Blog Posts

Comments

) } type DownloadProps = { url: string } const Download = ({ url }: DownloadProps) => (

Ratings:

420

420

420

4,200

4,200

4,200

)