Expose RSS feed

Though actually its the json feed 🤫
This commit is contained in:
Jonny Barnes 2023-12-19 17:12:49 +00:00
parent d264b8bdc3
commit ba9330cdf1
Signed by: jonny
SSH key fingerprint: SHA256:CTuSlns5U7qlD9jqHvtnVmfYV3Zwl2Z7WnJ4/dqOaL8
9 changed files with 41 additions and 2 deletions

View file

@ -102,7 +102,7 @@ class FeedsController extends Controller
*/
public function notesJson(): array
{
$notes = Note::latest()->with('media')->take(20)->get();
$notes = Note::latest()->with('media', 'place')->take(20)->get();
$data = [
'version' => 'https://jsonfeed.org/version/1',
'title' => 'The JSON Feed for ' . config('user.display_name') . 's notes',

File diff suppressed because one or more lines are too long

Binary file not shown.

View file

@ -19,4 +19,10 @@ a {
& a:visited {
color: var(--color-link);
}
& .rss-icon {
& svg {
color: var(--rss-color-link);
}
}
}

View file

@ -8,6 +8,13 @@
#site-header {
grid-column: 2 / 3;
grid-row: 1 / 2;
& .rss-icon {
& svg {
width: auto;
height: 1rem;
}
}
}
main {

View file

@ -19,4 +19,5 @@
--color-link: oklch(48.09% 0.146 241.41deg);
--color-link-visited: oklch(70.44% 0.21 304.41deg);
--color-primary-shadow: oklch(19.56% 0.054 125.505deg / 40%);
--rss-color-link: oklch(67.59% 0.189 42.04deg);
}

View file

@ -0,0 +1,13 @@
@php
if (isset($title)) {
$uniqueId = bin2hex(random_bytes(6));
}
@endphp
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-rss"
@if($title)aria-labelledby="{{ $uniqueId }}"@endif
>
@if($title)<title id="{{ $uniqueId }}">{{ $title }}</title>@endif
<path d="M4 11a9 9 0 0 1 9 9"></path>
<path d="M4 4a16 16 0 0 1 16 16"></path>
<circle cx="5" cy="19" r="1"></circle>
</svg>

View file

@ -47,6 +47,7 @@
<a href="/likes">Likes</a>
<a href="/contacts">Contacts</a>
<a href="/projects">Projects</a>
<a href="/notes/feed.json" class="rss-icon">@include('icons.rss', ['title' => 'RSS Feed'])</a>
</nav>
</header>

View file

@ -6,6 +6,7 @@ namespace Tests\Feature;
use App\Models\Article;
use App\Models\Note;
use App\Models\Place;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
@ -159,4 +160,14 @@ class FeedsTest extends TestCase
}
}
}
/** @test */
public function jsonNoteFeedLoadsPlaceDataWithoutLazyLoading(): void
{
$place = Place::factory()->create();
Note::factory()->create(['note' => null, 'place_id' => $place->id]);
$response = $this->get('/notes/feed.json');
$response->assertOk();
}
}