Skip to content

Commit 922d48f

Browse files
404 no matches spacing (#695)
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent 2e756ec commit 922d48f

2 files changed

Lines changed: 24 additions & 23 deletions

File tree

app/components/errors.tsx

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,15 @@ function ErrorPage({
112112
) : null}
113113
<HeroSection {...resolvedHeroProps} />
114114

115-
{possibleMatches ? (
115+
{possibleMatches?.length ? (
116116
<PossibleMatchesSection
117117
matches={possibleMatches}
118118
query={possibleMatchesQuery}
119119
/>
120120
) : null}
121121

122+
{possibleMatches?.length === 0 ? <Spacer size="lg" /> : null}
123+
122124
{articles?.length ? (
123125
<>
124126
<div id="articles" />
@@ -142,9 +144,7 @@ function PossibleMatchesSection({
142144
query?: string
143145
}) {
144146
const q = typeof query === 'string' ? query.trim() : ''
145-
const searchUrl = q ? `/search?q=${encodeURIComponent(q)}` : '/search'
146147
const sorted = sortNotFoundMatches(matches)
147-
const hasMatches = sorted.length > 0
148148

149149
return (
150150
<>
@@ -195,13 +195,6 @@ function PossibleMatchesSection({
195195
</li>
196196
))}
197197
</ul>
198-
<p className="mt-4 text-sm text-slate-500">
199-
{hasMatches ? 'None of these match? ' : 'No close matches found. '}
200-
<a href={searchUrl} className="underlined">
201-
Try semantic search
202-
</a>
203-
.
204-
</p>
205198
</div>
206199
</Grid>
207200
</>
@@ -233,10 +226,20 @@ function FourOhFour({
233226
const searchUrl = q ? `/search?q=${encodeURIComponent(q)}` : '/search'
234227
const hasPossibleMatches =
235228
Array.isArray(possibleMatchesProp) && possibleMatchesProp.length > 0
236-
const heroActionTo = hasPossibleMatches ? '#possible-matches' : searchUrl
237-
const heroActionLabel = hasPossibleMatches
238-
? 'Possible matches'
239-
: 'Search the site'
229+
const heroAction = hasPossibleMatches ? (
230+
<ArrowLink to="#possible-matches" className="whitespace-nowrap">
231+
Possible matches
232+
</ArrowLink>
233+
) : (
234+
<div className="space-y-2">
235+
<ArrowLink to={searchUrl} className="whitespace-nowrap">
236+
Search the site
237+
</ArrowLink>
238+
<p className="text-sm text-slate-500 dark:text-slate-400">
239+
Uses semantic search to find related content.
240+
</p>
241+
</div>
242+
)
240243

241244
// Most pages intentionally use the global `mx-10vw` gutter (it’s part of the
242245
// overall site layout). The 404 view reads better on mobile when it’s a bit
@@ -255,11 +258,7 @@ function FourOhFour({
255258
title: "404 - Oh no, you found a page that's missing stuff.",
256259
subtitle: `"${pathname}" is not a page on kentcdodds.com. So sorry.`,
257260
image: <MissingSomething className="rounded-lg" aspectRatio="3:4" />,
258-
action: (
259-
<ArrowLink to={heroActionTo} className="whitespace-nowrap">
260-
{heroActionLabel}
261-
</ArrowLink>
262-
),
261+
action: heroAction,
263262
}}
264263
/>
265264
</div>

app/components/sections/header-section.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface HeaderSectionProps {
88
cta?: string
99
as?: React.ElementType
1010
title: string
11-
subTitle: string
11+
subTitle?: string
1212
className?: string
1313
}
1414

@@ -30,9 +30,11 @@ function HeaderSection({
3030
>
3131
<div className="space-y-2 lg:space-y-0">
3232
<H2>{title}</H2>
33-
<H2 variant="secondary" as="p">
34-
{subTitle}
35-
</H2>
33+
{subTitle ? (
34+
<H2 variant="secondary" as="p">
35+
{subTitle}
36+
</H2>
37+
) : null}
3638
</div>
3739

3840
{cta && ctaUrl ? (

0 commit comments

Comments
 (0)