From 0fe8acad96a27bda4e6af0bc508c58e351029b07 Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Tue, 11 Jun 2024 09:44:56 +0200 Subject: [PATCH] wip --- app/Http/Controllers/InsightsController.php | 18 +++++++- .../front/pages/insights/index.blade.php | 10 +++++ .../partials/insightListItem.blade.php | 11 +++++ .../views/front/pages/insights/show.blade.php | 43 +++++++++++++++++++ .../livewire/newsletter-component.blade.php | 2 +- 5 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 resources/views/front/pages/insights/partials/insightListItem.blade.php diff --git a/app/Http/Controllers/InsightsController.php b/app/Http/Controllers/InsightsController.php index 4dd0433f0..e15ed5ba9 100644 --- a/app/Http/Controllers/InsightsController.php +++ b/app/Http/Controllers/InsightsController.php @@ -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; @@ -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); @@ -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, ]); } diff --git a/resources/views/front/pages/insights/index.blade.php b/resources/views/front/pages/insights/index.blade.php index d5a4e6048..4edbcad61 100644 --- a/resources/views/front/pages/insights/index.blade.php +++ b/resources/views/front/pages/insights/index.blade.php @@ -27,4 +27,14 @@ + +

+ From our team & products +

+ + @foreach($insights as $insight) + @include('front.pages.insights.partials.insightListItem') + @endforeach + + diff --git a/resources/views/front/pages/insights/partials/insightListItem.blade.php b/resources/views/front/pages/insights/partials/insightListItem.blade.php new file mode 100644 index 000000000..c4d40e2fe --- /dev/null +++ b/resources/views/front/pages/insights/partials/insightListItem.blade.php @@ -0,0 +1,11 @@ +
+ + {{ $insight->title }} + +
+ {{ $insight->website }} + +
+
+
diff --git a/resources/views/front/pages/insights/show.blade.php b/resources/views/front/pages/insights/show.blade.php index e69de29bb..a15940c3a 100644 --- a/resources/views/front/pages/insights/show.blade.php +++ b/resources/views/front/pages/insights/show.blade.php @@ -0,0 +1,43 @@ + + {{ $post->date?->format('d F Y') ?? 'Preview' }} + +

{{ $post->title }}

+ + @if($post->header_image) + + @endif + +
+ @foreach ($post->authors as $author) +
+ +
+

+ + + {{ $author->name }} + +

+
+
+ @endforeach +
+ +
+ {!! $post->content !!} +
+ + Back to insights + + @if(count($otherPosts)) +

Continue reading

+ @foreach($otherPosts as $otherPost) + + {{ $otherPost->title }} + {{ htmlspecialchars_decode(strip_tags($post->summary)) }} + + @endforeach + @endif + + +
diff --git a/resources/views/livewire/newsletter-component.blade.php b/resources/views/livewire/newsletter-component.blade.php index 3054abc74..57dbad1b3 100644 --- a/resources/views/livewire/newsletter-component.blade.php +++ b/resources/views/livewire/newsletter-component.blade.php @@ -31,7 +31,7 @@
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 Privacy Policy.
@endif