@@ -44,36 +44,18 @@ export async function POST(req: NextRequest) {
4444
4545 const data = JSON . parse ( body )
4646
47- const revalidateNewsroomPages = async ( ) => {
48- console . log ( new Date ( ) , 'Revalidating: /news' )
49- revalidateTag ( 'newsroom' , 'max' )
50- //revalidatePath('/news')
51- //revalidatePath('/no/nyheter')
52- }
53-
5447 if ( data . _type === 'news' ) {
5548 // wait for news index and revalidate...
5649 const response = await updateAlgoliaIndex ( body )
5750 if ( Number ( response . status ) === 200 ) {
5851 const algoliaTaskIds = await response . json ( )
5952 console . log ( 'Algolia Indexing Success' , algoliaTaskIds )
60- // wait for a second revalidate newsroom pages
61- /* const sleep = (delay: number) =>
62- new Promise(resolve => setTimeout(resolve, delay))
63- await sleep(1000) // wait for a second to let algolia index temporary fix as we dont know the status yet
64- */
65- // Extract and wait for all tasks in parallel
66- /*const tasks = algoliaTaskIds.map((taskID: number) => {
67- const envPrefix = Flags.IS_GLOBAL_PROD ? 'prod' : 'dev'
68- const indexName = `${envPrefix}_NEWS_${data.language}`
69- return algoliaClient.waitForTask({
70- indexName: indexName,
71- taskID: taskID,
72- })
73- })
74- const statuses = await Promise.all(tasks)
75- console.log('Algolia Indexing Statuses:', statuses)*/
76- await revalidateNewsroomPages ( )
53+ console . log (
54+ new Date ( ) ,
55+ 'Revalidating by tag ' ,
56+ `newsroom_${ data . language } ` ,
57+ )
58+ revalidateTag ( `newsroom_${ data . language } ` , 'max' )
7759 return new Response (
7860 JSON . stringify ( { message : 'Index updated and newsroom revalidated' } ) ,
7961 { status : 200 } ,
0 commit comments