Update JSON notes feed to version 1.1
This commit is contained in:
parent
24ca9f86d2
commit
2aa60db548
4 changed files with 20 additions and 13 deletions
|
@ -102,12 +102,18 @@ class FeedsController extends Controller
|
|||
*/
|
||||
public function notesJson(): array
|
||||
{
|
||||
$notes = Note::latest()->with('media', 'place')->take(20)->get();
|
||||
$notes = Note::latest()->with('media', 'place', 'tags')->take(20)->get();
|
||||
$data = [
|
||||
'version' => 'https://jsonfeed.org/version/1',
|
||||
'version' => 'https://jsonfeed.org/version/1.1',
|
||||
'title' => 'The JSON Feed for ' . config('user.display_name') . '’s notes',
|
||||
'home_page_url' => config('app.url') . '/notes',
|
||||
'feed_url' => config('app.url') . '/notes/feed.json',
|
||||
'authors' => [
|
||||
[
|
||||
'name' => config('user.display_name'),
|
||||
'url' => config('app.url'),
|
||||
],
|
||||
],
|
||||
'items' => [],
|
||||
];
|
||||
|
||||
|
@ -115,13 +121,13 @@ class FeedsController extends Controller
|
|||
$data['items'][$key] = [
|
||||
'id' => $note->longurl,
|
||||
'url' => $note->longurl,
|
||||
'content_html' => $note->content,
|
||||
'content_text' => $note->content,
|
||||
'date_published' => $note->created_at->tz('UTC')->toRfc3339String(),
|
||||
'date_modified' => $note->updated_at->tz('UTC')->toRfc3339String(),
|
||||
'author' => [
|
||||
'name' => config('user.display_name'),
|
||||
],
|
||||
];
|
||||
if ($note->tags->count() > 0) {
|
||||
$data['items'][$key]['tags'] = implode(',', $note->tags->pluck('tag')->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue