Skip to content

Commit 1bc25b4

Browse files
committed
Improve caching
1 parent 36708af commit 1bc25b4

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

next.config.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
module.exports = {
33
reactStrictMode: true,
44
images: {
5-
domains: ["cdn.discordapp.com", "discord.com", "i.imgur.com"]
6-
}
5+
domains: ["cdn.discordapp.com", "discord.com", "i.imgur.com"],
6+
minimumCacheTTL: 3600
7+
},
8+
poweredByHeader: false
79
}

pages/characters/[name].tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @next/next/no-img-element */
12
import { GetStaticPathsResult, GetStaticPropsContext, GetStaticPropsResult } from "next"
23
import Head from "next/head"
34
import Image from "next/image"
@@ -91,7 +92,7 @@ function AscensionCosts({ costs }: { costs: CostTemplate }) {
9192
return <div className="flex flex-row items-center">
9293
<div className="text-base font-semibold pt-1 inline-block pr-1 h-9">Ascension materials:</div>
9394
{ascensionCosts.map(e => <div className="inline-block pr-1 w-6 h-6 md:h-8 md:w-8" key={e}>
94-
<Image src={image("material", e)} alt={e} width={256} height={256} />
95+
<img src={image("material", e)} alt={e} width={256} height={256} />
9596
</div>)}
9697
</div>
9798
}
@@ -119,7 +120,7 @@ function FullAscensionCosts({ template, costTemplates }: { template: CostTemplat
119120
<div className="flex flex-row align-middle items-center">
120121
<div>{count}&times;</div>
121122
<div className="pr-1 w-6 h-6 md:h-8 md:w-8">
122-
<Image src={image("material", name)} alt={name} width={256} height={256} />
123+
<img src={image("material", name)} alt={name} width={256} height={256} />
123124
</div>
124125
<div>{name}</div></div>}
125126
</td>)}
@@ -156,7 +157,7 @@ function TalentCosts({ skills }: { skills: Skills[] }) {
156157
return <div className="flex flex-row items-center">
157158
<div className="text-base font-semibold pt-1 inline-block pr-1 h-9">Talent materials:</div>
158159
{all.map(e => <div className="inline-block pr-1 w-6 h-6 md:h-8 md:w-8" key={e}>
159-
<Image src={image("material", e)} alt={e} width={256} height={256} />
160+
<img src={image("material", e)} alt={e} width={256} height={256} />
160161
</div>)}
161162
</div>
162163
}

pages/characters/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,11 @@ function ToggleButton<T>({ type, value, setter, children }: { type: T[], value:
185185

186186

187187
function Icon({ char, className }: { char: SmallChar, className?: string }) {
188-
let src = char.icon ?? "img/unknown.png"
188+
const src = char.icon ?? "img/unknown.png"
189189

190-
if (src.startsWith("img")) src = "/" + src
190+
if (src.startsWith("img"))
191+
// eslint-disable-next-line @next/next/no-img-element
192+
return <img alt={char.name} src={"/" + src} className={className} width={256} height={256} onError={(e) => (e.target as HTMLImageElement).src = "/img/unknown.png"} loading="eager" />
191193

192194
return <Image alt={char.name} src={src} className={className} width={256} height={256} onError={(e) => (e.target as HTMLImageElement).src = "/img/unknown.png"} loading="eager" />
193195
}

0 commit comments

Comments
 (0)