Files
Christophe Coevoet 495b4ac8f4 Inline the static website generator in the website repo
Maintaining a standalone static website generator project that is not
reused outside our website adds maintenance overhead. For instance,
support for using `phpdocumentor/guides` was implemented in the website
repo rather than the standalone generator package, which was still using
the `doctrine/rst-parser` package that we want to abandon.
2025-10-09 21:46:37 +02:00

39 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace Doctrine\Website\DataSources;
use Doctrine\Website\StaticGenerator\SourceFile\SourceFileFilesystemReader;
final readonly class BlogPosts implements DataSource
{
public function __construct(
private SourceFileFilesystemReader $sourceFileFilesystemReader,
) {
}
/** @return mixed[][] */
public function getSourceRows(): array
{
$sourceFiles = $this->sourceFileFilesystemReader
->getSourceFiles()->in('/blog/');
$blogPosts = [];
foreach ($sourceFiles as $sourceFile) {
$blogPosts[] = [
'url' => $sourceFile->getParameter('url'),
'slug' => $sourceFile->getParameter('slug'),
'title' => $sourceFile->getParameter('title'),
'authorName' => (string) $sourceFile->getParameter('authorName'),
'authorEmail' => (string) $sourceFile->getParameter('authorEmail'),
'contents' => $sourceFile->getContents(),
'date' => $sourceFile->getDate(),
];
}
return $blogPosts;
}
}