mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(not found page): only show 'back to p/...' button if subplebbitAddress is in valid format; limit img size
This commit is contained in:
@@ -41,6 +41,8 @@
|
|||||||
.boxContent img {
|
.boxContent img {
|
||||||
display: block;
|
display: block;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
|
max-height: 500px;
|
||||||
|
max-width: 500px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.backToBoard {
|
.backToBoard {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { Link, useParams } from 'react-router-dom';
|
import { Link, useLocation } from 'react-router-dom';
|
||||||
import { HomeLogo } from '../home';
|
import { HomeLogo } from '../home';
|
||||||
import styles from './not-found.module.css';
|
import styles from './not-found.module.css';
|
||||||
import Plebbit from '@plebbit/plebbit-js/dist/browser/index.js';
|
import { useSubplebbit } from '@plebbit/plebbit-react-hooks';
|
||||||
|
|
||||||
const totalNotFoundImages = 2;
|
const totalNotFoundImages = 2;
|
||||||
|
|
||||||
@@ -16,8 +16,10 @@ const NotFoundImage = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const NotFound = () => {
|
const NotFound = () => {
|
||||||
const { subplebbitAddress } = useParams();
|
const location = useLocation();
|
||||||
const isValidSubplebbitAddress = !subplebbitAddress || subplebbitAddress.includes('.') || /^12D3K[a-zA-Z0-9]{44}$/.test(subplebbitAddress);
|
const subplebbitAddress = location.pathname.startsWith('/p/') ? location.pathname.split('/')[2] : '';
|
||||||
|
const subplebbit = useSubplebbit({ subplebbitAddress });
|
||||||
|
const { address, shortAddress } = subplebbit || {};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.wrapper}>
|
<div className={styles.wrapper}>
|
||||||
@@ -30,11 +32,11 @@ const NotFound = () => {
|
|||||||
</div>
|
</div>
|
||||||
<div className={styles.boxContent}>
|
<div className={styles.boxContent}>
|
||||||
<NotFoundImage />
|
<NotFoundImage />
|
||||||
{subplebbitAddress && isValidSubplebbitAddress && (
|
{address && (
|
||||||
<>
|
<>
|
||||||
<br />
|
<br />
|
||||||
<div className={styles.backToBoard}>
|
<div className={styles.backToBoard}>
|
||||||
[<Link to={`/p/${subplebbitAddress}`}>Back to p/{Plebbit.getShortAddress(subplebbitAddress)}</Link>]
|
[<Link to={`/p/${subplebbitAddress}`}>Back to p/{shortAddress}</Link>]
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user