feat: prepare CMS pages for deployment

This commit is contained in:
Codex
2026-04-29 14:23:00 +08:00
parent 9a55b874a5
commit d4fb7e0973
87 changed files with 5153 additions and 1901 deletions
@@ -4,12 +4,13 @@ import { revalidatePath } from 'next/cache'
import { redirect } from 'next/navigation'
const CACHE_PATHS = [
'/sitemap.xml',
'/en',
'/zh',
'/en/about',
'/zh/about',
'/en/dealers',
'/zh/dealers',
'/en/where-to-buy',
'/zh/where-to-buy',
'/en/downloads',
'/zh/downloads',
'/en/news',
@@ -54,3 +55,11 @@ export async function clearFrontendCache(formData: FormData) {
redirect(`${returnTo}${returnTo.includes('?') ? '&' : '?'}cache=cleared`)
}
export async function refreshSitemapCache(formData: FormData) {
const returnTo = normalizeReturnPath(formData.get('returnTo'))
revalidatePath('/sitemap.xml')
redirect(`${returnTo}${returnTo.includes('?') ? '&' : '?'}sitemap=refreshed`)
}
@@ -1,12 +1,13 @@
'use client'
import { usePathname, useSearchParams } from 'next/navigation'
import { clearFrontendCache } from './admin-cache-actions'
import { clearFrontendCache, refreshSitemapCache } from './admin-cache-actions'
export function AdminCacheButton() {
const pathname = usePathname()
const searchParams = useSearchParams()
const cacheCleared = searchParams.get('cache') === 'cleared'
const sitemapRefreshed = searchParams.get('sitemap') === 'refreshed'
const returnTo = pathname || '/admin'
if (pathname === '/admin/login') return null
@@ -23,6 +24,16 @@ export function AdminCacheButton() {
{cacheCleared ? 'Cache cleared' : 'Clear cache'}
</button>
</form>
<form action={refreshSitemapCache}>
<input type="hidden" name="returnTo" value={returnTo} />
<button
className="admin-cache-header-slot__button"
type="submit"
title={sitemapRefreshed ? 'Sitemap refreshed.' : 'Force refresh sitemap.xml'}
>
{sitemapRefreshed ? 'Sitemap refreshed' : 'Refresh sitemap'}
</button>
</form>
</div>
)
}