File tree Expand file tree Collapse file tree 2 files changed +17
-13
lines changed Expand file tree Collapse file tree 2 files changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -124,14 +124,15 @@ export async function generateMetadata({
124
124
params : Promise < SlugPageParams >
125
125
} ) {
126
126
const { locale, slug } = await params
127
- const t = await getTranslations ( { locale, namespace : "common" } )
128
127
129
128
try {
130
129
return await getMdMetadata ( {
131
130
locale,
132
131
slug,
133
132
} )
134
133
} catch ( error ) {
134
+ const t = await getTranslations ( { locale, namespace : "common" } )
135
+
135
136
// Return basic metadata for invalid paths
136
137
return {
137
138
title : t ( "page-not-found" ) ,
Original file line number Diff line number Diff line change @@ -147,23 +147,26 @@ export async function generateMetadata({
147
147
} ) {
148
148
const { locale } = await params
149
149
150
- // If invalid locale, return not-found metadata title
151
- if ( ! LOCALES_CODES . includes ( locale ) ) {
150
+ try {
151
+ const t = await getTranslations ( { locale, namespace : "page-index" } )
152
+ return await getMetadata ( {
153
+ locale,
154
+ slug : [ "" ] ,
155
+ title : t ( "page-index-meta-title" ) ,
156
+ description : t ( "page-index-meta-description" ) ,
157
+ } )
158
+ } catch ( error ) {
152
159
const t = await getTranslations ( {
153
160
locale : DEFAULT_LOCALE ,
154
161
namespace : "common" ,
155
162
} )
156
- return { title : t ( "we-couldnt-find-that-page" ) }
157
- }
158
-
159
- const t = await getTranslations ( { locale, namespace : "page-index" } )
160
163
161
- return await getMetadata ( {
162
- locale ,
163
- slug : [ "" ] ,
164
- title : t ( "page-index-meta-title " ) ,
165
- description : t ( "page-index-meta-description" ) ,
166
- } )
164
+ // Return basic metadata for invalid paths
165
+ return {
166
+ title : t ( "page-not-found" ) ,
167
+ description : t ( "page-not-found-description " ) ,
168
+ }
169
+ }
167
170
}
168
171
169
172
export default Page
You can’t perform that action at this time.
0 commit comments