';
$items = scandir($dirPath);
sort($items);
@@ -196,15 +196,36 @@ class CodePressCMS {
$itemName = ucfirst(pathinfo($item, PATHINFO_FILENAME));
if (is_dir($path)) {
- $content .= '
';
- $content .= ' ' . $itemName;
- $content .= '';
+ $content .= '
';
+ $content .= '
';
+ $content .= '
';
+ $content .= '
';
+ $content .= '
';
} elseif (preg_match('/\.(md|php|html)$/', $item)) {
// Remove extension from URL for cleaner links
$cleanPath = preg_replace('/\.[^.]+$/', '', $relativePath);
- $content .= '
';
- $content .= ' ' . $itemName;
- $content .= '';
+
+ // Get preview content
+ $preview = '';
+ $fileContent = file_get_contents($path);
+
+ // Extract title if possible
+ $fileTitle = $itemName;
+ if (preg_match('/^#\s+(.+)$/m', $fileContent, $matches)) {
+ $fileTitle = trim($matches[1]);
+ }
+
+ // Extract preview text (first paragraph)
+ $fileContent = strip_tags($this->parseMarkdown($fileContent)['content']);
+ $preview = substr($fileContent, 0, 150) . '...';
+
+ $content .= '
';
+ $content .= '
';
+ $content .= '
';
+ $content .= '
';
+ $content .= '
' . $preview . '
';
+ $content .= '
Lees meer';
+ $content .= '
';
}
}