File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed
Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,9 @@ import { Directions, ImagePositionMainPageDesktop } from '@/lib/selects'
33import { colorField } from '@lib/utils/colors'
44import { MainPageImage } from '@/payload-types'
55import draftAccess from '@/lib/utils/access'
6+ import { routing } from '@/i18n/routing'
7+ import { revalidatePath } from 'next/cache'
8+ import purgeRoute from '@/lib/utils/purge'
69
710const MainPage : GlobalConfig = {
811 slug : 'mainPageImages' ,
@@ -222,6 +225,24 @@ const MainPage: GlobalConfig = {
222225 } ,
223226 } ,
224227 } ,
228+ hooks : {
229+ afterChange : [
230+ async ( { req, doc } ) => {
231+ if ( doc . _status === 'published' ) {
232+ const updatedLocale = req . locale
233+ if ( updatedLocale === 'all' )
234+ routing . locales . map ( async ( locale ) => {
235+ revalidatePath ( `/${ locale } ` )
236+ await purgeRoute ( `${ locale } ` )
237+ } )
238+ else {
239+ revalidatePath ( `/${ updatedLocale } ` )
240+ await purgeRoute ( `${ updatedLocale } ` )
241+ }
242+ }
243+ } ,
244+ ] ,
245+ } ,
225246}
226247
227248export default MainPage
Original file line number Diff line number Diff line change 11import { GlobalConfig } from 'payload'
22import { colorField } from '@/lib/utils/colors'
33import draftAccess from '@/lib/utils/access'
4+ import { routing } from '@/i18n/routing'
5+ import { revalidatePath } from 'next/cache'
6+ import purgeRoute from '@/lib/utils/purge'
47
58export const Sculptures : GlobalConfig = {
69 slug : 'sculpture' ,
@@ -97,4 +100,22 @@ export const Sculptures: GlobalConfig = {
97100 } ,
98101 } ,
99102 } ,
103+ hooks : {
104+ afterChange : [
105+ async ( { req, doc } ) => {
106+ if ( doc . _status === 'published' ) {
107+ const updatedLocale = req . locale
108+ if ( updatedLocale === 'all' )
109+ routing . locales . map ( async ( locale ) => {
110+ revalidatePath ( `/${ locale } /sculptures` )
111+ await purgeRoute ( `${ locale } /sculptures` )
112+ } )
113+ else {
114+ revalidatePath ( `/${ updatedLocale } /sculptures` )
115+ await purgeRoute ( `${ updatedLocale } /sculptures` )
116+ }
117+ }
118+ } ,
119+ ] ,
120+ } ,
100121}
You can’t perform that action at this time.
0 commit comments