Skip to content

Commit 143769a

Browse files
committed
feat: improve rss feed
1 parent a24aaf5 commit 143769a

File tree

4 files changed

+35
-30
lines changed

4 files changed

+35
-30
lines changed

src/Web/Blog/Author.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ enum Author: string
66
{
77
case BRENT = 'brent';
88

9+
public function getFullName(): string
10+
{
11+
return match ($this) {
12+
self::BRENT => 'Brent Roose',
13+
};
14+
}
15+
916
public function getName(): string
1017
{
1118
return match ($this) {

src/Web/Blog/BlogPost.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Web\Blog;
44

5+
use App\Web\Meta\MetaImageController;
56
use DateTimeImmutable;
67

78
use function Tempest\uri;
@@ -18,8 +19,9 @@ final class BlogPost
1819
public bool $published = true;
1920
public array $meta = [];
2021
public string $uri {
21-
get {
22-
return uri([BlogController::class, 'show'], slug: $this->slug);
23-
}
22+
get => uri([BlogController::class, 'show'], slug: $this->slug);
23+
}
24+
public string $metaImageUri {
25+
get => uri([MetaImageController::class, 'blog'], slug: $this->slug);
2426
}
2527
}

src/Web/Blog/rss.view.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,28 @@
33
/** @var \App\Web\Blog\BlogPost[] $posts */
44
?>
55

6-
<feed xmlns="http://www.w3.org/2005/Atom">
6+
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/">
77
<id>https://tempestphp.com/rss</id>
8-
<link href="https://tempestphp.com/rss"/>
9-
<title><![CDATA[ tempestphp.com ]]></title>
8+
<link rel="self" type="application/atom+xml" href="https://tempestphp.com/rss" />
9+
<title>Tempest</title>
1010
<updated><?= date('c') ?></updated>
11-
1211
<?php foreach ($posts as $post): ?>
1312
<entry>
1413
<title><![CDATA[ <?= $post->title ?> ]]></title>
15-
1614
<link rel="alternate" href="<?= $post->uri ?>"/>
17-
1815
<id><?= $post->uri ?></id>
19-
16+
<category term="PHP" />
2017
<author>
21-
<name><![CDATA[ Brent Roose ]]></name>
18+
<name><?= $post->author->getFullName() ?></name>
19+
<uri><?= $post->author->getBluesky() ?></uri>
2220
</author>
23-
24-
<summary type="html"><![CDATA[ <?= $post->content ?> ]]></summary>
25-
21+
<?php if ($post->description): ?>
22+
<summary type="html"><![CDATA[ <?= $post->description ?> ]]></summary>
23+
<?php endif; ?>
24+
<content type="html"><![CDATA[ <?= $post->content ?> ]]></content>
2625
<updated><?= $post->createdAt->format('c') ?></updated>
26+
<published><?= $post->createdAt->format('c') ?></published>
27+
<media:content url="<?= $post->metaImageUri ?>" medium="image" />
2728
</entry>
2829
<?php endforeach; ?>
2930
</feed>

src/Web/Blog/show.view.php

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,39 @@
11
<?php
2-
32
/** @var \App\Web\Blog\BlogPost $post */
4-
use App\Web\Meta\MetaImageController;
5-
6-
use function Tempest\uri;
7-
83
?>
94

105
<x-base
11-
:meta-image-uri="uri([MetaImageController::class, 'blog'], slug: $post->slug)"
12-
:title="$post->title"
13-
:description="$post->description"
14-
:copy-code-blocks="true"
15-
:meta="$post->meta"
6+
:meta-image-uri="$post->metaImageUri"
7+
:title="$post->title"
8+
:description="$post->description"
9+
:copy-code-blocks="true"
10+
:meta="$post->meta"
1611
>
1712
<!-- Main container -->
18-
<main class="container px-4 mx-auto xl:px-8 flex flex-col grow isolate items-center relative">
13+
<main class="isolate relative flex flex-col items-center mx-auto px-4 xl:px-8 container grow">
1914
<!-- Main content -->
20-
<article class="grow px-2 flex flex-col w-full md:w-auto min-w-0 lg:mt-10 max-w-3xl">
15+
<article class="flex flex-col lg:mt-10 px-2 w-full md:w-auto min-w-0 max-w-3xl grow">
2116
<!-- Breadcrumbs -->
2217
<nav class="text-(--ui-text-dimmed) font-medium flex items-center mb-4 text-sm gap-x-1.5">
23-
<x-icon name="tabler:news" class="size-5 mr-1" />
18+
<x-icon name="tabler:news" class="mr-1 size-5" />
2419
<a :href="uri([BlogController::class, 'index'])" class="hover:text-(--ui-text) transition">Blog</a>
2520
<span>/</span>
2621
<span class="text-(--ui-primary)">{{ $post->title }}</span>
2722
</nav>
2823
<!-- Header -->
2924
<div class="flex flex-col pb-8 border-b border-(--ui-border) max-w-[65ch]">
30-
<h1 class="text-3xl font-bold tracking-tight text-gray-900 dark:text-white sm:text-4xl lg:text-5xl">
25+
<h1 class="font-bold text-gray-900 dark:text-white text-3xl sm:text-4xl lg:text-5xl tracking-tight">
3126
{{ $post->title }}
3227
</h1>
33-
<p class="mt-4 text-lg text-gray-500 dark:text-gray-400">
28+
<p class="mt-4 text-gray-500 dark:text-gray-400 text-lg">
3429
{{ $post->description }}
3530
</p>
3631
<span :if="$post->author" class="text-(--ui-text-muted) text-sm mt-8">
3732
by <span class="font-medium">{{ $post->author->getName() }}</span> on <span class="font-medium">{{ $post->createdAt->format('F d, Y') }}</span>
3833
</span>
3934
</div>
4035
<!-- Content -->
41-
<div class="prose dark:prose-invert mt-8 pb-24 space-y-12 w-full">
36+
<div class="space-y-12 dark:prose-invert mt-8 pb-24 w-full prose">
4237
{!! $post->content !!}
4338
</div>
4439
</article>

0 commit comments

Comments
 (0)