Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/app/(profile)/profile/[destinyMembershipId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,7 @@ export default async function Page({ params }: PageProps) {

export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
if (!isValidDestinyMembershipId(params.destinyMembershipId)) {
return {
robots: {
follow: true,
index: false
}
}
notFound()
}

const [profile, basic] = await Promise.all([
Expand Down
6 changes: 4 additions & 2 deletions src/app/clan/[groupId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ export default async function Page({ params }: PageProps) {

export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
if (!isValidClanGroupId(params.groupId)) {
return {}
notFound()
}

const clan = await getClan(params.groupId)

if (!clan) return {}
if (!clan) {
notFound()
}

const clanName = fixClanName(clan.detail.name)

Expand Down
11 changes: 1 addition & 10 deletions src/app/clan/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { getClanBannerSource } from "bungie-net-core/endpoints/Destiny2"
import { getGroup } from "bungie-net-core/endpoints/GroupV2"
import { notFound } from "next/navigation"
import { BungiePlatformError } from "~/models/BungieAPIError"
import ServerBungieClient from "~/services/bungie/ServerBungieClient"
import { reactRequestDedupe } from "~/util/react-cache"
Expand All @@ -16,8 +15,6 @@ const clanClient = new ServerBungieClient({
timeout: 6000
})

const expectedErrorCodes = [1, 7, 621, 622, 686]

export const getClan = reactRequestDedupe(async (groupId: string) =>
getGroup(clanClient, { groupId })
.then(res => {
Expand All @@ -26,13 +23,7 @@ export const getClan = reactRequestDedupe(async (groupId: string) =>
}
return res.Response
})
.catch(err => {
if (err instanceof BungiePlatformError && expectedErrorCodes.includes(err.ErrorCode)) {
notFound()
} else {
return null
}
})
.catch(() => null)
)

const bannerClient = new ServerBungieClient({
Expand Down
8 changes: 2 additions & 6 deletions src/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
"use client"

import { PageWrapper } from "~/components/PageWrapper"

export default function NotFound() {
return (
<PageWrapper>
<div className="mx-auto mt-2 mb-6 w-[95%] lg:w-[90%] xl:w-[85%]">
<h1>{"Not found :("}</h1>
</PageWrapper>
</div>
)
}
13 changes: 5 additions & 8 deletions src/app/pgcr/[instanceId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Metadata } from "next"
import { notFound } from "next/navigation"

import { PageWrapper } from "~/components/PageWrapper"
import PGCR from "~/components/pgcr/pgcr-view"
Expand All @@ -10,6 +11,7 @@ import {
tryPrefetchActivity
} from "~/lib/pgcr/server"
import { type PGCRPageProps } from "~/lib/pgcr/types"
import { isValidInstanceId } from "~/util/destiny/routeParams"

export const revalidate = 0

Expand All @@ -24,19 +26,14 @@ export default async function Page({ params }: PGCRPageProps) {
}

export async function generateMetadata({ params }: PGCRPageProps): Promise<Metadata> {
if (!/^\d+$/.test(params.instanceId)) {
return {}
if (!isValidInstanceId(params.instanceId)) {
notFound()
}

const activity = await tryPrefetchActivity(params.instanceId)

if (!activity) {
return {
robots: {
follow: true,
index: false
}
}
notFound()
}

const { idTitle, ogTitle, description } = getMetaData(activity)
Expand Down
Loading