@@ -274,31 +274,24 @@ export const Projects: CollectionConfig = {
274274 } ,
275275 hooks : {
276276 afterChange : [
277- async ( { doc, req } ) => {
277+ async ( { doc } ) => {
278278 // Ignore draft updates
279279 // Only revalidate cache when a document has been published
280280 if ( doc . _status === 'published' ) {
281- const updatedLocale = req . locale
282281 const updateURL = `/projects/${ doc . id } `
283282
284- // If all locales were updated then revalidate all languages otherwise only the updated locale
285- if ( updatedLocale === 'all' )
286- routing . locales . forEach ( async ( locale ) => {
287- revalidatePath ( `/${ locale } ${ updateURL } ` )
288- await purgeURL ( `${ locale } ${ updateURL } ` ) // Purge nginx cache
289-
290- // Revalidate projects page in case name or thumbnail were changed
291- revalidatePath ( `/${ locale } /projects` )
292- await purgeURL ( `${ locale } /projects` )
293- } )
294- else {
295- revalidatePath ( `/${ updatedLocale } ${ updateURL } ` )
296- await purgeURL ( `${ updatedLocale } ${ updateURL } ` )
283+ // Revalidate all locales since when making changes not related
284+ // to localization it only updates that locale instead of all.
285+ // Revalidating everything (even if not needed) is an ease of use
286+ // tradeoff.
287+ routing . locales . forEach ( async ( locale ) => {
288+ revalidatePath ( `/${ locale } ${ updateURL } ` )
289+ await purgeURL ( `${ locale } ${ updateURL } ` ) // Purge nginx cache
297290
298291 // Revalidate projects page in case name or thumbnail were changed
299- revalidatePath ( `/${ updatedLocale } /projects` )
300- await purgeURL ( `${ updatedLocale } /projects` )
301- }
292+ revalidatePath ( `/${ locale } /projects` )
293+ await purgeURL ( `${ locale } /projects` )
294+ } )
302295 }
303296 } ,
304297 ] ,
0 commit comments