Skip to content
This repository was archived by the owner on May 1, 2022. It is now read-only.

Commit

Permalink
404 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mdellabitta committed Jun 23, 2021
1 parent 5f79098 commit 5d63c82
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/HomePage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const HomePage = ({ siteName }) => {

return (
<>
<Link href={'/item/072c5702a83b7fc48a0b7899c231d5d3'}><a><div style={{
<Link href={'/search'}><a><div style={{
backgroundImage: 'url("https://bscdn-images.dp.la/072c5702a83b7fc48a0b7899c231d5d3.jpg")',
width: '800px',
height: '523px',
Expand Down
21 changes: 20 additions & 1 deletion pages/item/[itemId].js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ import {
joinIfArray,
getItemThumbnail,
} from "lib";
import Error from "next/error";

const ItemDetail = ({ err, url, item }) => {

console.log("ERR", err);

if (err) return <Error statusCode={err}/>

const ItemDetail = ({ url, item }) => {
return (
<MainLayout>
<BSCDNHead
Expand Down Expand Up @@ -51,8 +57,21 @@ export async function getServerSideProps(context) {
const currentUrl = getCurrentUrl(req);
try {
const res = await fetch(`${currentUrl}${API_ENDPOINT}/${itemId}`);

const json = await res.json();

if (json === "Not Found") {
console.log("couldn't find it")
res.statusCode = 404

return {
props: {
err: 404,
error: `Item not found`
}
}
}

const doc = json.docs[0];
const image = process.env.FULL_FRAME_IMAGES ? `https://bscdn-images.dp.la/${doc.id}.jpg` : getItemThumbnail(doc)
const date = doc.sourceResource.date &&
Expand Down

0 comments on commit 5d63c82

Please sign in to comment.