summaryrefslogtreecommitdiff
path: root/lib/revalidate.ts
blob: 08c572ee0ba03d223e4a6598c3220f7e3863e162 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"use server"

import { revalidatePath } from "next/cache"
import { languages } from "@/i18n/settings"

/**
 * 지정된 base 경로에 대해 지원 언어별로 revalidatePath를 호출합니다.
 * 예: basePath가 "/evcp/approval/line" 이면
 *  - /ko/evcp/approval/line
 *  - /en/evcp/approval/line
 * 등의 경로를 무효화합니다.
 */
export async function revalidateI18nPaths(basePath: string): Promise<void> {
  for (const lng of languages) {
    try {
      revalidatePath(`/${lng}${basePath}`)
    } catch {
      // ignore
    }
  }
}

/**
 * 여러 base 경로를 한 번에 무효화합니다.
 */
export async function revalidateI18nPathsMany(basePaths: string[]): Promise<void> {
  for (const basePath of basePaths) {
    await revalidateI18nPaths(basePath)
  }
}