Skip to content

Commit 56eea4b

Browse files
committed
wip
1 parent dfda340 commit 56eea4b

File tree

4 files changed

+29
-40
lines changed

4 files changed

+29
-40
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"type": "project",
44
"description": "Documentation website for the Tempest framework",
55
"require": {
6-
"tempest/framework": "^2.2.1",
6+
"tempest/framework": "^2.3",
77
"league/commonmark": "^2.7.1",
88
"symfony/yaml": "^7.3.3",
99
"spatie/yaml-front-matter": "^2.1",

composer.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Web/Blog/BlogController.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Tempest\Support\Arr\ImmutableArray;
1515
use Tempest\View\View;
1616

17+
use Tempest\View\ViewRenderer;
1718
use function Tempest\view;
1819

1920
final readonly class BlogController
@@ -43,24 +44,17 @@ public function show(string $slug, BlogRepository $repository): Response|View
4344
#[Get('/rss')]
4445
public function rss(
4546
Cache $cache,
47+
ViewRenderer $viewRenderer,
4648
BlogRepository $repository,
47-
): Response {
49+
): Response
50+
{
4851
$xml = $cache->resolve(
4952
key: 'rss',
50-
callback: fn () => $this->renderRssFeed($repository->all(loadContent: true)),
53+
callback: fn () => $viewRenderer->render(view('rss.view.php', posts: $repository->all(loadContent: true))),
5154
expiration: DateTime::now()->plusHours(1),
5255
);
5356

5457
return new Ok($xml)
5558
->addHeader('Content-Type', 'application/xml;charset=UTF-8');
5659
}
57-
58-
private function renderRssFeed(ImmutableArray $posts): string
59-
{
60-
ob_start();
61-
62-
include __DIR__ . '/rss.view.php';
63-
64-
return trim(ob_get_clean());
65-
}
6660
}

src/Web/Blog/rss.view.php

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
11
<?php
2-
32
/** @var \App\Web\Blog\BlogPost[] $posts */
43
?>
54

65
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/">
76
<id>https://tempestphp.com/rss</id>
8-
<link rel="self" type="application/atom+xml" href="https://tempestphp.com/rss" />
7+
<link rel="self" type="application/atom+xml" href="https://tempestphp.com/rss"/>
98
<title>Tempest</title>
109
<updated><?= date('c') ?></updated>
11-
<?php foreach ($posts as $post): ?>
12-
<entry>
13-
<title><![CDATA[ <?= $post->title ?> ]]></title>
14-
<link rel="alternate" href="<?= $post->uri ?>"/>
15-
<id><?= $post->uri ?></id>
16-
<category term="PHP" />
17-
<author>
18-
<name><?= $post->author->getFullName() ?></name>
19-
<uri><?= $post->author->getBluesky() ?></uri>
20-
</author>
21-
<?php if ($post->description): ?>
22-
<summary type="html"><![CDATA[ <?= $post->description ?> ]]></summary>
23-
<?php endif; ?>
24-
<content type="html"><![CDATA[ <?= $post->content ?> ]]></content>
25-
<updated><?= $post->createdAt->format('c') ?></updated>
26-
<published><?= $post->createdAt->format('c') ?></published>
27-
<media:content url="<?= $post->metaImageUri ?>" medium="image" />
28-
</entry>
29-
<?php endforeach; ?>
10+
<entry :foreach="$posts as $post">
11+
<title><![CDATA[ {!! $post->title !!} ]]></title>
12+
<link rel="alternate" :href="$post->uri"/>
13+
<id>{{ $post->uri }}</id>
14+
<category term="PHP"/>
15+
<author>
16+
<name>{{ $post->author->getFullName() }}</name>
17+
<uri>{{ $post->author->getBluesky() }}</uri>
18+
</author>
19+
<summary :if="$post->description" type="html"><![CDATA[ {!! $post->description !!} ]]></summary>
20+
<content type="html"><![CDATA[ {!! $post->content !!} ]]></content>
21+
<updated>{{ $post->createdAt->format('c') }}</updated>
22+
<published>{{ $post->createdAt->format('c') }}</published>
23+
<media:content url="{{ $post->metaImageUri }}" medium="image"/>
24+
</entry>
3025
</feed>

0 commit comments

Comments
 (0)