]*>(.*?)<\/h1>/is', $content, $titleMatch)) {
$title = strip_tags($titleMatch[1]);
} else {
$title = pathinfo($file, PATHINFO_FILENAME);
}
if (preg_match('/
]+src=["\']([^"\'>]+)["\']/i', $content, $imgMatch)) {
$image = $imgMatch[1];
} else {
$image = 'images/default-cover.jpg';
}
$posts[] = [
'title' => $title,
'image' => $image,
'file' => $file,
];
}
?>