import { useState } from 'react'; import { Link, useLocation } from 'react-router-dom'; import useSubplebbitsStore from '@plebbit/plebbit-react-hooks/dist/stores/subplebbits'; import { HomeLogo } from '../home'; import styles from './not-found.module.css'; import { NOT_FOUND_IMAGES } from '../../generated/asset-manifest'; const NotFoundImage = () => { const [imagePath] = useState(() => NOT_FOUND_IMAGES[Math.floor(Math.random() * NOT_FOUND_IMAGES.length)]); return ; }; const NotFound = () => { const location = useLocation(); // Extract boardIdentifier from pathname (could be directory code or address) const pathParts = location.pathname.split('/').filter(Boolean); const boardIdentifier = pathParts[0] && pathParts[0] !== 'not-found' && pathParts[0] !== 'faq' ? pathParts[0] : ''; const subplebbitAddress = boardIdentifier || ''; const subplebbit = useSubplebbitsStore((state) => state.subplebbits[subplebbitAddress]); const { address, shortAddress } = subplebbit || {}; return (

404 Not Found

{address && ( <>
[Back to p/{shortAddress}]
)}
); }; export default NotFound;