on master help sign in
pages/group, id: add 404 fallbacks
commit76065d9848de1dc13a6906495636b41b1ca5760d authorMatilde Park <matilde.park@urbit.org> dateTue 26 Apr 2022, 17:32 (4 years ago) parentdc1dded
4 files changed+65−21
components/gateway/Gateway404.js+45 components/gateway/GatewayHeader.js+4−2 pages/group/[[...group]].js+7−9 pages/id/[id].js+9−10
components/gateway/Gateway404.jsnew file+45
@@ -0,0 +1,45 @@
1+import GatewayHeader from "./GatewayHeader";
2+import Container from "../Container";
3+import SingleColumn from "../SingleColumn";
4+import Section from "../Section";
5+import Link from "next/link";
6+
7+const Gateway404 = ({ type }) => {
8+ const error = (
9+ <div className="overflow-hidden rounded-xl">
10+ <svg
11+ width="100"
12+ height="100"
13+ viewBox="0 0 100 100"
14+ fill="none"
15+ xmlns="http://www.w3.org/2000/svg"
16+ >
17+ <rect width="100" height="100" rx="10" fill="#24201E" />
18+ <path
19+ d="M28.8906 27.9844C28.5019 28.0215 28.1699 28.2833 28.043 28.6524C27.914 29.0235 28.0137 29.4336 28.2969 29.7032L70.2969 71.7032C70.4844 71.8965 70.7402 72.0059 71.0098 72.0059C71.2773 72.0079 71.5352 71.9004 71.7246 71.709C71.9141 71.5176 72.0176 71.2598 72.0137 70.9903C72.0098 70.7227 71.8984 70.4668 71.7031 70.2813L66.2501 64.8283C69.8204 60.9181 72.0001 55.7073 72.0001 50.0003C72.0001 37.8618 62.1386 28.0003 50.0001 28.0003C44.2931 28.0003 39.0976 30.1956 35.1876 33.7658L29.7031 28.2813C29.4922 28.0645 29.1934 27.9551 28.8906 27.9844L28.8906 27.9844ZM50.0001 30C61.0566 30 70.0001 38.9435 70.0001 50C70.0001 55.17 68.0411 59.8575 64.8281 63.406L36.5936 35.1715C40.1405 31.9606 44.8336 29.9995 49.9996 29.9995L50.0001 30ZM32.1721 37.8125C31.842 37.8321 31.5452 38.0137 31.3752 38.2969C29.2424 41.6856 28.0002 45.7029 28.0002 49.9999C28.0002 62.1384 37.8617 71.9999 50.0002 71.9999C54.2951 71.9999 58.3147 70.7558 61.7032 68.6249C62.1739 68.3319 62.3165 67.7128 62.0235 67.2421C61.7305 66.7714 61.1114 66.6288 60.6407 66.9218C57.5587 68.8593 53.9122 69.9999 50.0002 69.9999C38.9437 69.9999 30.0002 61.0564 30.0002 49.9999C30.0002 46.0878 31.1233 42.4414 33.0627 39.3594C33.2697 39.043 33.2815 38.6387 33.092 38.3125C32.9045 37.9844 32.5491 37.7929 32.1721 37.8125L32.1721 37.8125Z"
20+ fill="white"
21+ />
22+ </svg>
23+ </div>
24+ );
25+
26+ return (
27+ <Container>
28+ <SingleColumn>
29+ <Section narrow className="space-y-12">
30+ <GatewayHeader
31+ title="Error 404"
32+ error={error}
33+ item={`No ${type} at this address`}
34+ />
35+ <hr className="text-wall-200" />
36+ <Link href="/">
37+ <a className="text-xl block font-semibold">Urbit.org</a>
38+ </Link>
39+ </Section>
40+ </SingleColumn>
41+ </Container>
42+ );
43+};
44+
45+export default Gateway404;
components/gateway/GatewayHeader.js+4−2
@@ -1,10 +1,11 @@
1−const GatewayHeader = ({ image, sigil, title, item }) => {
1+const GatewayHeader = ({ image, sigil, error, title, item }) => {
22 return (
33 <div className="flex items-center space-x-4">
44 {image ? (
55 <img className="rounded-xl" src={image} height={100} width={100} />
66 ) : (
7− !sigil && (
7+ !sigil &&
8+ !error && (
89 <img
910 className="object-contain shadow-sm rounded-xl"
1011 style={{ height: 100, width: 100 }}
@@ -12,6 +13,7 @@ const GatewayHeader = ({ image, sigil, title, item }) => {
1213 />
1314 )
1415 )}
16+ {error && error}
1517 {sigil && sigil}
1618 <div className="flex flex-col">
1719 <h2>{title}</h2>
pages/group/[[...group]].js+7−9
@@ -6,11 +6,11 @@ import Meta from "../../components/Meta";
66import CopyLink from "../../components/CopyLink";
77import Container from "../../components/Container";
88import SingleColumn from "../../components/SingleColumn";
9−import ErrorPage from "../404";
109import Section from "../../components/Section";
1110import ob from "urbit-ob";
1211import Markdown from "../../components/Markdown";
1312import GatewayHeader from "../../components/gateway/GatewayHeader";
13+import Gateway404 from "../../components/gateway/Gateway404";
1414import MetadataBlock from "../../components/gateway/MetadataBlock";
1515import MetadataLink from "../../components/gateway/MetadataLink";
1616import Description from "../../components/gateway/Description";
@@ -18,7 +18,7 @@ import Description from "../../components/gateway/Description";
1818const GroupPage = ({ data, markdown, params }) => {
1919 const { group } = params;
2020 if (!ob.isValidPatp(group[0])) {
21− return <ErrorPage />;
21+ return <Gateway404 type="group" />;
2222 }
2323 const image = `https://urbit-id-og-cards-ltjw3771z-urbit.vercel.app/${
2424 data.title
@@ -52,13 +52,11 @@ const GroupPage = ({ data, markdown, params }) => {
5252 </Head>
5353 <SingleColumn>
5454 <Section className="space-y-12" narrow>
55− <div className="flex items-center space-x-4">
56− <GatewayHeader
57− title={data.title}
58− image={data?.image}
59− item="Urbit ID"
60− />
61− </div>
55+ <GatewayHeader
56+ title={data.title}
57+ image={data?.image}
58+ item="Urbit ID"
59+ />
6260 <div className="flex flex-wrap md:flex-nowrap justify-between">
6361 <MetadataBlock
6462 title="Group Type"
pages/id/[id].js+9−10
@@ -11,6 +11,7 @@ import ob from "urbit-ob";
1111import Markdown from "../../components/Markdown";
1212import Sigil from "../../components/Sigil";
1313import GatewayHeader from "../../components/gateway/GatewayHeader";
14+import Gateway404 from "../../components/gateway/Gateway404";
1415import MetadataBlock from "../../components/gateway/MetadataBlock";
1516import MetadataLink from "../../components/gateway/MetadataLink";
1617import Description from "../../components/gateway/Description";
@@ -19,7 +20,7 @@ import axios from "axios";
1920const IdPage = ({ data, markdown, network, params }) => {
2021 const { id } = params;
2122 if (!ob.isValidPatp(id) || id.length > 14) {
22− return <ErrorPage />;
23+ return <Gateway404 type="ID" />;
2324 }
2425
2526 const image = `https://urbit-id-og-cards-kappa.vercel.app/${deSig(id)}.png`;
@@ -63,15 +64,13 @@ const IdPage = ({ data, markdown, network, params }) => {
6364 <meta property="twitter:image" content={image} key="image" />
6465 </Head>
6566 <SingleColumn>
66− <Section className="space-y-12" narrow>
67− <div className="flex items-center space-x-4">
68− <GatewayHeader
69− title={id}
70− image={data?.image || false}
71− sigil={sigil}
72− item="Urbit ID"
73− />
74− </div>
67+ <Section className="space-y-12 w-full" narrow>
68+ <GatewayHeader
69+ title={id}
70+ image={data?.image || false}
71+ sigil={sigil}
72+ item="Urbit ID"
73+ />
7574 <div className="flex flex-wrap md:flex-nowrap justify-between">
7675 <MetadataBlock
7776 title="ID Type"