'English','it'=>'Italiano','nl'=>'Nederlands','cs'=>'Čeština','es'=>'Español','tr'=>'Türkçe','de'=>'Deutsch','fr'=>'Français']; $raw=parse_url($_SERVER['REQUEST_URI']??'/',PHP_URL_PATH) ?: '/'; $parts=explode('/',trim($raw,'/')); $locale='en'; if(isset($parts[0])&&in_array($parts[0],$locales,true)){$locale=array_shift($parts);} $path=implode('/',$parts); $base=$locale==='en'?'':'/'.$locale; $config=json_decode((string)file_get_contents(__DIR__."/data/$locale/config.json"),true)?:[]; $payload=json_decode((string)file_get_contents(__DIR__."/data/$locale/posts.json"),true)?:[]; $posts=$payload['data']??[]; $site=$config['site']??['name'=>'Genify Next','description'=>'AI news and practical guides.']; $cats=$config['categories']??[]; $catMap=[]; foreach($cats as $c)$catMap[$c['slug']]=$c; $tr=$config['translations']??[]; $ui=$tr['ui']??[]; $home=$tr['homepage']??[]; function e($v):string{return htmlspecialchars((string)$v,ENT_QUOTES|ENT_SUBSTITUTE,'UTF-8');} function href(string $p):string{global $base; return $base.'/'.ltrim($p,'/');} function val($a,$k,$d=''){return $a[$k]??$d;} function post_by_slug(array $ps,string $s):?array{foreach($ps as $p)if(($p['slug']??'')===$s)return $p;return null;} function img(array $p):string{$u=$p['featured_image_url']??$p['featured_image']??'';return is_string($u)&&str_starts_with($u,'/img/')?$u:'';} function blocks(array $bs):string{$h='';foreach($bs as $b){if(!is_array($b))continue;$t=$b['type']??'paragraph';$c=$b['content']??'';if($t==='image'){$u=$b['image_url']??$b['src']??'';if(is_string($u)&&str_starts_with($u,'/img/'))$h.='
'.e($b['alt']??$c).'
'.e($c).'
';continue;}if(in_array($t,['header','heading'],true)){$n=min(6,max(2,(int)($b['level']??2)));$h.=''.e($c).'';}elseif(in_array($t,['introduction','paragraph','text'],true)){foreach(preg_split('/\R\s*\R/',$c) as $p)if(trim($p)!=='')$h.='

'.nl2br(e(trim($p))).'

';}}return $h;} function header_html(string $title):string{global $site,$cats,$names,$locales,$locale,$ui; $homeLabel=val($ui['nav']??[],'home','Home');$nav=''.e($homeLabel).'';foreach($cats as $c)$nav.=''.e($c['name']).'';$langs='';foreach($locales as $l)$langs.=''.e($names[$l]).''; $langs.='';return ''.e($title).' — '.e($site['name']).'Genify Next
'.$langs.'
';} function foot():string{return '
';} function card(array $p):string{$u=img($p);return '
'.($u?'':'').'
'.e($p['category']??'AI').'

'.e($p['title']??'').'

'.e($p['excerpt']??'').'

'.e('Read more').' →
';} if($path===''||$path==='index.php'){$body='

GENIFY NEXT

'.e(val($home['hero']??[],'title','Understand AI Models and Put Them to Work')).'

'.e(val($home['hero']??[],'subtitle',$site['description']??'' )).'

'.e(val($home,'latest_title','Latest AI News, Models, and Guides')).'

';foreach($posts as $p)$body.=card($p);$body.='
';echo header_html($site['name']).$body.foot();exit;} if(str_starts_with($path,'category/')){$s=substr($path,9);$cat=$catMap[$s]??['name'=>ucwords(str_replace('-',' ',$s)),'description'=>''];$body='

CATEGORY

'.e($cat['name']).'

'.e($cat['description']??'').'

';foreach($posts as $p)if(strtolower((string)($p['category']??''))===strtolower((string)($cat['name']??''))||($p['category_slug']??'')===$s)$body.=card($p);$body.='
';echo header_html($cat['name']).$body.foot();exit;} foreach(($config['pages']??[]) as $pg)if(($pg['slug']??'')===$path){$t=$pg['title']??ucwords($path);echo header_html($t).'

'.e($t).'

'.e($site['description']??'').'

'.foot();exit;} $p=post_by_slug($posts,$path);if($p){$body='

'.e($p['category']??'AI').'

'.e($p['title']??'').'

'.e($p['excerpt']??'').'

';if($u=img($p))$body.='';$body.=blocks($p['content_blocks']??[]).'
';echo header_html($p['title']).$body.foot();exit;}http_response_code(404);echo header_html('Page not found').'

Page not found

Back to home

'.foot(); ?>