Skip to content

Commit 4a899f3

Browse files
committed
updated llms.txt
Signed-off-by: bidi47 <bidi@apidemia.com>
1 parent 7f2b4f8 commit 4a899f3

4 files changed

Lines changed: 46 additions & 9 deletions

File tree

‎src/App/src/Factory/LlmsGeneratorFactory.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function __invoke(ContainerInterface $container): LlmsGenerator
2525
$config['llms']['indexFile'],
2626
$config['application']['url'] ?? '',
2727
$config['llms']['pagesDir'] ?? null,
28+
$config['application']['meta']['title'] ?? 'Dotkernel',
2829
);
2930
}
3031
}

‎src/App/src/Service/LlmsGenerator.php‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public function __construct(
6969
private readonly string $outputFile,
7070
private readonly string $baseUrl,
7171
private readonly ?string $pagesDir = null,
72+
private readonly string $title = 'Dotkernel',
7273
) {
7374
}
7475

@@ -138,7 +139,7 @@ private function buildCategorySection(string $slug, array $entries): string
138139
{
139140
$category = $entries[0]['post']->getCategory();
140141
$heading = sprintf(
141-
'## %s (%d post%s)',
142+
'### %s (%d post%s)',
142143
$category->getName(),
143144
count($entries),
144145
count($entries) === 1 ? '' : 's',
@@ -153,7 +154,7 @@ private function buildCategorySection(string $slug, array $entries): string
153154

154155
foreach ($entries as $entry) {
155156
$lines[] = sprintf(
156-
'- [%s](%s/%s/%s/): %s',
157+
'- [%s](%s/%s/%s.md): %s',
157158
$entry['title'],
158159
$this->baseUrl,
159160
$slug,
@@ -218,7 +219,7 @@ private function buildPagesSection(): string
218219
$lines = ['## Pages', ''];
219220
foreach ($pages as $page) {
220221
$lines[] = sprintf(
221-
'- [%s](%s/%s/): %s',
222+
'- [%s](%s/md-pages/%s.md): %s',
222223
$page['title'],
223224
$this->baseUrl,
224225
$page['slug'],
@@ -240,7 +241,7 @@ private function extractFrontMatterField(string $contents, string $field): ?stri
240241

241242
private function buildHeader(): string
242243
{
243-
$intro = '> Dotkernel Light is the technical blog for the Dotkernel headless PHP platform - a PSR-15 '
244+
$intro = '> Dotkernel is the technical blog for the Dotkernel headless PHP platform - a PSR-15 '
244245
. 'compliant application built on Mezzio and Laminas components. It publishes architecture '
245246
. 'write-ups, how-tos, and release notes for the platform applications - Dotkernel API, Admin '
246247
. 'and Queue - and for the standalone Dotkernel Light skeleton.';
@@ -253,7 +254,7 @@ private function buildHeader(): string
253254
$about = 'the team behind Dotkernel - how the team works, its commitment to open source and the PHP '
254255
. 'community, and how it uses AI under guardrails';
255256

256-
return "# Dotkernel Light\n\n"
257+
return "# {$this->title}\n\n"
257258
. $intro . "\n\n"
258259
. $body . "\n\n"
259260
. "## Docs\n\n"

‎test/Unit/App/Factory/LlmsGeneratorFactoryTest.php‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,36 @@ public function testInvokeAppliesTheConfiguredValues(): void
2626
'indexFile' => '/tmp/llms.txt',
2727
'pagesDir' => '/tmp/md-pages',
2828
],
29-
'application' => ['url' => 'https://example.test'],
29+
'application' => [
30+
'url' => 'https://example.test',
31+
'meta' => ['title' => 'Custom Title'],
32+
],
3033
]));
3134

3235
$this->assertSame('/tmp/llms.txt', $generator->getOutputFile());
3336
$this->assertSame('/tmp/md-articles', $this->readProperty($generator, 'sourceDir'));
3437
$this->assertSame('/tmp/md-pages', $this->readProperty($generator, 'pagesDir'));
3538
$this->assertSame('https://example.test', $this->readProperty($generator, 'baseUrl'));
39+
$this->assertSame('Custom Title', $this->readProperty($generator, 'title'));
40+
}
41+
42+
/**
43+
* A config without a meta title (e.g. the `application.meta` section is absent) simply
44+
* keeps the historical default.
45+
*
46+
* @throws Exception
47+
*/
48+
public function testInvokeFallsBackToTheDefaultTitleWhenItIsNotConfigured(): void
49+
{
50+
$generator = (new LlmsGeneratorFactory())($this->createContainer([
51+
'llms' => [
52+
'sourceDir' => '/tmp/md-articles',
53+
'indexFile' => '/tmp/llms.txt',
54+
],
55+
'application' => ['url' => 'https://example.test'],
56+
]));
57+
58+
$this->assertSame('Dotkernel', $this->readProperty($generator, 'title'));
3659
}
3760

3861
/**

‎test/Unit/App/Service/LlmsGeneratorTest.php‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,21 @@ public function testWriteReturnsZeroAndWritesOnlyTheHeaderWhenThereAreNoPublishe
8787
$this->assertSame(0, $this->createGenerator()->write());
8888

8989
$output = $this->writtenOutput();
90-
$this->assertStringStartsWith('# Dotkernel Light', $output);
90+
$this->assertStringStartsWith('# Dotkernel', $output);
9191
$this->assertStringContainsString('## Categories', $output);
9292
$this->assertStringNotContainsString('## (', $output);
9393
}
9494

95+
/**
96+
* @throws Exception
97+
*/
98+
public function testWriteUsesTheConfiguredTitleAsTheHeading(): void
99+
{
100+
$this->createGenerator(title: 'Custom Blog Title')->write();
101+
102+
$this->assertStringStartsWith('# Custom Blog Title', $this->writtenOutput());
103+
}
104+
95105
/**
96106
* @throws Exception
97107
*/
@@ -211,14 +221,14 @@ public function testWriteUsesSingularPostWordingForACategoryWithExactlyOnePost()
211221
/**
212222
* @throws Exception
213223
*/
214-
public function testWriteBuildsEachPostLinkFromTheBaseUrlCategorySlugAndPostSlug(): void
224+
public function testWriteBuildsEachPostLinkFromTheBaseUrlCategorySlugAndPostSlugAsMarkdown(): void
215225
{
216226
$posts = [$this->createPost('A post', 'a-post', 'dotkernel', 'Dotkernel')];
217227

218228
$this->createGenerator($posts, baseUrl: 'https://example.test')->write();
219229

220230
$this->assertStringContainsString(
221-
'[A post](https://example.test/dotkernel/a-post/):',
231+
'[A post](https://example.test/dotkernel/a-post.md):',
222232
$this->writtenOutput()
223233
);
224234
}
@@ -397,6 +407,7 @@ private function createGenerator(
397407
?string $outputFile = null,
398408
string $baseUrl = 'https://example.test',
399409
?string $pagesDir = '',
410+
string $title = 'Dotkernel',
400411
): LlmsGenerator {
401412
$postRepository = $this->createStub(PostRepository::class);
402413
$postRepository->method('getPublishedPosts')->willReturn($posts);
@@ -407,6 +418,7 @@ private function createGenerator(
407418
$outputFile ?? $this->outputFile,
408419
$baseUrl,
409420
$pagesDir === '' ? $this->pagesDir : $pagesDir,
421+
$title,
410422
);
411423
}
412424

0 commit comments

Comments
 (0)