import type { PublicArticle } from '@/types'; const API_URL = process.env.API_URL || 'http://localhost:24731'; export async function getPublishedArticles(): Promise { try { const response = await fetch(`${API_URL}/api/public/articles?pageSize=100`, { next: { revalidate: 60 }, }); if (!response.ok) return []; const data = await response.json(); return data.list || []; } catch { return []; } } export async function getPublishedArticle(identifier: string): Promise { try { const response = await fetch(`${API_URL}/api/public/articles/${encodeURIComponent(identifier)}`, { next: { revalidate: 60 }, }); if (!response.ok) return null; return response.json(); } catch { return null; } } export const articleUrl = (article: Pick) => `/knowledge/${article.slug || article.content_id}`;