Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Jun 11, 2024
1 parent 7653378 commit 0fe8aca
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 3 deletions.
18 changes: 16 additions & 2 deletions app/Http/Controllers/InsightsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Controllers;

use App\Models\Insight;
use Spatie\ContentApi\ContentApi;
use Spatie\ContentApi\Data\Post;
use Spatie\Feed\FeedItem;
Expand All @@ -17,17 +18,23 @@ public function index()
unset($posts[0]);
}

$insights = Insight::query()
->orderBy('created_at', 'desc')
->limit(6)
->get();

return view('front.pages.insights.index', [
'posts' => $posts,
'firstPost' => $firstPost ?? null,
'insights' => $insights,
]);
}

public function detail(string $slug)
{
$post = ContentApi::getPost('spatie', $slug, theme: 'nord');
$post = ContentApi::getPost('ray', $slug, theme: 'nord');

if (! $post && is_numeric(explode('-', $slug)[0])) {
if (!$post && is_numeric(explode('-', $slug)[0])) {
$parts = explode('-', $slug);

$parts = array_slice($parts, 1);
Expand All @@ -37,8 +44,15 @@ public function detail(string $slug)

abort_if(is_null($post), 404);

$otherPosts = ContentApi::getPosts('ray', 1, 3, theme: 'nord')
->filter(function (Post $otherPost) use ($post) {
return $otherPost->slug !== $post->slug;
})
->take(2);

return view('front.pages.insights.show', [
'post' => $post,
'otherPosts' => $otherPosts,
]);
}

Expand Down
10 changes: 10 additions & 0 deletions resources/views/front/pages/insights/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,14 @@
</section>

<livewire:newsletter />

<h2>
From our team & products
</h2>

@foreach($insights as $insight)
@include('front.pages.insights.partials.insightListItem')
@endforeach


</x-page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div>
<a href="{{ $insight->url }}">
{{ $insight->title }}

<div>
<time
datetime="{{ $post->date->format('Y-m-d') }}">{{ $post->date->format('d F Y') }}</time> {{ $insight->website }}

</div>
</a>
</div>
43 changes: 43 additions & 0 deletions resources/views/front/pages/insights/show.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<x-page title="Blog" background="/backgrounds/blogs.jpg">
{{ $post->date?->format('d F Y') ?? 'Preview' }}

<h1>{{ $post->title }}</h1>

@if($post->header_image)
<img class="w-full rounded-md my-4" alt="" src="{{ $post->header_image }}"/>
@endif

<div>
@foreach ($post->authors as $author)
<div class="flex items-center gap-x-2">
<img src="{{ $author->gravatar_url }}" alt="" class="h-6 w-6 rounded-full bg-indigo-50">
<div class="text-[0.6rem] leading-6">
<p class="font-semibold text-indigo-900">
<span>
<span class="absolute inset-0"></span>
{{ $author->name }}
</span>
</p>
</div>
</div>
@endforeach
</div>

<div>
{!! $post->content !!}
</div>

<a href="{{ route('insights') }}">Back to insights</a>

@if(count($otherPosts))
<h2>Continue reading</h2>
@foreach($otherPosts as $otherPost)
<a href="{{ route('insights.show', $otherPost->slug) }}">
{{ $otherPost->title }}
{{ htmlspecialchars_decode(strip_tags($post->summary)) }}
</a>
@endforeach
@endif

<livewire:newsletter-component/>
</x-page>
2 changes: 1 addition & 1 deletion resources/views/livewire/newsletter-component.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</div>
<div>
Sign up for occasional emails on Spatie products and promotions.
By submitting this from, you acknowledge our [Privacy Policy]({{ route('legal.privacy') }}).
By submitting this from, you acknowledge our <a href="{{ route('legal.privacy') }}">Privacy Policy</a>.
</div>
</div>
@endif
Expand Down

0 comments on commit 0fe8aca

Please sign in to comment.