diff options
Diffstat (limited to 'lib/revalidate.ts')
| -rw-r--r-- | lib/revalidate.ts | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/revalidate.ts b/lib/revalidate.ts new file mode 100644 index 00000000..08c572ee --- /dev/null +++ b/lib/revalidate.ts @@ -0,0 +1,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) + } +} + + |
