Skip to content

Commit caf2546

Browse files
authored
tv llm txt (#1517)
* cs * kick of llms.txt file
1 parent 84d5eed commit caf2546

File tree

5 files changed

+56
-14
lines changed

5 files changed

+56
-14
lines changed

resources/views/llms-txt.blade.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@php
2+
/** @var \App\Entity\Post[] $posts */
3+
@endphp
4+
5+
6+
# Tomas Votruba
7+
8+
I help PHP companies to modernize their codebase,
9+
increase profits and attract new talent.
10+
11+
To make this happen faster and at scale, I made Rector - software that handles instant upgrades and automated refactoring.
12+
13+
We provide an upgrade service to save you time and money.
14+
15+
16+
17+
# Blog posts
18+
19+
@foreach ($posts as $post)
20+
## {{ $post->getTitle() }}
21+
22+
{!! $post->getContent() !!}
23+
24+
@endforeach

routes/web.php

+2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
// include dots and slashes as well
2020
->where('slug', '.*');
2121

22+
Route::get('llms.txt', \App\Http\Controllers\LlmsTxtController::class);
2223
Route::redirect('/rss.xml', '/rss');
24+
2325
Route::get('/rss', RssController::class);
2426

2527
Route::get('/thumbnail/{title}.png', ThumbnailController::class)
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Http\Controllers;
6+
7+
use App\Repository\PostRepository;
8+
use Illuminate\Http\Response;
9+
use Illuminate\Routing\Controller;
10+
11+
final class LlmsTxtController extends Controller
12+
{
13+
public function __construct(
14+
private readonly PostRepository $postRepository
15+
) {
16+
}
17+
18+
public function __invoke(): Response
19+
{
20+
$response = response()->view('llms-txt', [
21+
'posts' => $this->postRepository->fetchAll(),
22+
])->header('Content-Type', 'text/plain');
23+
24+
return $response;
25+
}
26+
}

src/Http/Controllers/PostController.php

+2-7
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,9 @@
1111

1212
final class PostController extends Controller
1313
{
14-
public function __construct(
15-
private readonly PostRepository $postRepository,
16-
) {
17-
}
18-
19-
public function __invoke(string $slug): View|RedirectResponse
14+
public function __invoke(string $slug, PostRepository $postRepository): View|RedirectResponse
2015
{
21-
$post = $this->postRepository->getBySlug($slug);
16+
$post = $postRepository->getBySlug($slug);
2217

2318
if ($post->getAlias() && $post->getAlias() !== $slug) {
2419
return redirect('/blog/' . $post->getAlias());

src/Http/Controllers/RssController.php

+2-7
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,9 @@
1212

1313
final class RssController extends Controller
1414
{
15-
public function __construct(
16-
private readonly PostRepository $postRepository,
17-
) {
18-
}
19-
20-
public function __invoke(): Response
15+
public function __invoke(PostRepository $postRepository): Response
2116
{
22-
$posts = $this->postRepository->fetchAll();
17+
$posts = $postRepository->fetchAll();
2318

2419
$contents = view('rss', [
2520
'posts' => $posts,

0 commit comments

Comments
 (0)