<?php
header('Content-Type: application/json');
$dataPath = 'data/news.json';

if (file_exists($dataPath)) {
    $auto = json_decode(file_get_contents('data/news.json'), true);
    $manual = json_decode(file_get_contents('admin/posts.json'), true);
    echo json_encode(array_merge($manual, $auto));

    // Confirm it's a valid array before echoing
    if (is_array($decoded)) {
        echo json_encode($decoded);
    } else {
        echo json_encode([]);
    }
} else {
    echo json_encode([]);
}
?>
