import { getTranslations, setRequestLocale } from 'next-intl/server'; import Link from 'next/link'; import { Header } from '@/components/Header'; import { Footer } from '@/components/Footer'; import { createDb, skillReviewQueries } from '@skillhub/db'; import { getPageAlternates } from '@/lib/seo'; import { getOrSetCache, cacheKeys, cacheTTL } from '@/lib/cache'; import { ShieldAlert, Ban, ExternalLink } from 'lucide-react'; export const dynamic = 'force-dynamic'; async function getMalwareData(page: number, limit: number) { try { return await getOrSetCache(cacheKeys.malwarePage(page), cacheTTL.malware, async () => { const db = createDb(); const offset = (page - 1) * limit; const [skills, total] = await Promise.all([ skillReviewQueries.getMaliciousSkills(db, limit, offset), skillReviewQueries.countMaliciousSkills(db), ]); return { skills, total }; }); } catch (error) { console.error('Error fetching malware skills:', error); return { skills: [], total: 0 }; } } export async function generateMetadata({ params, }: { params: Promise<{ locale: string }>; }) { const { locale } = await params; return { alternates: getPageAlternates(locale, '/malware'), }; } export default async function MalwarePage({ params, searchParams, }: { params: Promise<{ locale: string }>; searchParams: Promise<{ page?: string }>; }) { const { locale } = await params; const searchParamsResolved = await searchParams; setRequestLocale(locale); const t = await getTranslations('malwarePage'); const tMalicious = await getTranslations('malicious'); const limit = 20; const page = parseInt(searchParamsResolved.page || '1'); const { skills: malwareSkills } = await getMalwareData(page, limit); return (
{/* Header */}

{t('title')}

{t('subtitle')}

{malwareSkills.length === 0 ? (

{t('noResults')}

) : (
{malwareSkills.map((skill) => (
{skill.name || skill.id} {tMalicious('badge')}

{skill.githubOwner}/{skill.githubRepo}

{skill.description && (

{skill.description}

)}
{t('downloadBlocked')} {t('installBlocked')}
GitHub
))}
)} {/* Back to stats link */}
← {locale === 'fa' ? 'بازگشت به آمار بررسی‌ها' : 'Back to Review Statistics'}
); }