Skip to content

Commit

Permalink
Make new blog public
Browse files Browse the repository at this point in the history
sebastiandedeyne committed Jan 29, 2025
1 parent 1eed137 commit db6ec33
Showing 17 changed files with 149 additions and 277 deletions.
6 changes: 3 additions & 3 deletions app/Http/Controllers/BlogController.php
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ public function index(): View
->orderBy('created_at', 'desc')
->paginate(7);

return view('front.pages.insights.index', [
return view('front.pages.blog.index', [
'posts' => $posts,
'highlight' => $highlight ?? null,
'externalFeedItems' => $externalFeedItems,
@@ -39,7 +39,7 @@ public function all(): View

unset($posts[0]);

return view('front.pages.insights.index', [
return view('front.pages.blog.index', [
'posts' => $posts,
'highlight' => $highlight ?? null,
]);
@@ -67,7 +67,7 @@ public function detail(string $slug): View|RedirectResponse
})
->take(2);

return view('front.pages.insights.show', [
return view('front.pages.blog.show', [
'post' => $post,
'content' => $content,
'otherPosts' => $otherPosts,
16 changes: 0 additions & 16 deletions app/Http/Controllers/BlogsController.php

This file was deleted.

23 changes: 0 additions & 23 deletions app/Http/Controllers/MusicController.php

This file was deleted.

1 change: 0 additions & 1 deletion app/Providers/NavigationServiceProvider.php
Original file line number Diff line number Diff line change
@@ -27,7 +27,6 @@ public function register(): void
// ->route('vacancies.index', 'Vacancies')
->route('about', 'About')
->route('blog', 'Blog')
// ->route('insights', 'Insights')
->route('docs', 'Docs')
->route('guidelines', 'Guidelines')
->addIf(auth()->check(), View::create('layout.partials.navigation.profileIcon', ['url' => route('profile')]))
22 changes: 17 additions & 5 deletions app/Providers/ViewServiceProvider.php
Original file line number Diff line number Diff line change
@@ -5,8 +5,10 @@
use App\Models\ExternalFeedItem;
use App\Models\Member;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use Spatie\ContentApi\ContentApi;

class ViewServiceProvider extends ServiceProvider
{
@@ -16,12 +18,22 @@ public function boot(): void
return "<?php echo app_svg({$expression}); ?>";
});

View::composer('front.pages.open-source.partials.insights', function ($view): void {
$view->with('externalFeedItems', ExternalFeedItem::getLatest());
});

View::composer('front.pages.home.partials.news', function ($view): void {
$view->with('externalFeedItems', ExternalFeedItem::getLatest());
$view->with(
'latestBlogPost',
Cache::flexible('home.latestBlogPost', [60, 60 * 60], function () {
return ContentApi::getPosts(
product: 'spatie',
page: request('page', 1),
perPage: 1,
)->first();
}),
);

$view->with(
'externalFeedItems',
ExternalFeedItem::getLatest(),
);
});

View::composer('front.pages.about.partials.team', function ($view): void {
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<?php /** @var \Spatie\ContentApi\Data\Post $insight */ ?>
<div wire:navigate href="{{ route('insights.show', $insight->slug) }}" class="insights-list-item relative cursor-pointer flex flex-col sm:flex-row gap-3 sm:gap-8 group mx-0 sm:p-9 {{ $class ?? '' }}">
<div wire:navigate href="{{ route('blog.show', $insight->slug) }}" class="insights-list-item relative cursor-pointer flex flex-col sm:flex-row gap-3 sm:gap-8 group mx-0 sm:p-9 {{ $class ?? '' }}">
<div class="absolute inset-0 rounded-[20px] pointer-events-none w-full h-full opacity-50 border {{ ($border ?? false) ? 'bg-link-card-light-hover border-oss-gray-dark' : 'border-transparent' }} group-hover:bg-link-card-light-hover group-hover:border-oss-gray-dark"></div>
<figure>
<a wire:navigate href="{{ route('insights.show', $insight->slug) }}" class="text-oss-royal-blue no-underline block w-[120px] h-[120px] bg-oss-green-pale rounded-8">
<a wire:navigate href="{{ route('blog.show', $insight->slug) }}" class="text-oss-royal-blue no-underline block w-[120px] h-[120px] bg-oss-green-pale rounded-8">
@if ($insight->header_image)
<img class="w-full h-full object-cover rounded-8" src="{{ $insight->header_image }}" alt="">
@endif
</a>
</figure>
<div>
<h3 class="text-24 leading-snug font-bold normal-case mb-3 group-hover:text-oss-spatie-blue hover:text-oss-spatie-blue">
<a wire:navigate href="{{ route('insights.show', $insight->slug) }}" class="text-oss-royal-blue no-underline">
<a wire:navigate href="{{ route('blog.show', $insight->slug) }}" class="text-oss-royal-blue no-underline">
{{ $insight->title }}
</a>
</h3>
<a wire:navigate href="{{ route('insights.show', $insight->slug) }}" class="text-oss-royal-blue no-underline block mt-3 [&_p]:mt-2 [&_code]:text-16 [&_code]:bg-transparent">
<a wire:navigate href="{{ route('blog.show', $insight->slug) }}" class="text-oss-royal-blue no-underline block mt-3 [&_p]:mt-2 [&_code]:text-16 [&_code]:bg-transparent">
{!! $insight->summary !!}
</a>
<a wire:navigate href="{{ route('insights.show', $insight->slug) }}" class="text-oss-royal-blue no-underline mt-4 flex gap-3 text-14">
<a wire:navigate href="{{ route('blog.show', $insight->slug) }}" class="text-oss-royal-blue no-underline mt-4 flex gap-3 text-14">
@isset($insight->date)
<time datetime="{{ $insight->date->format('Y-m-d') }}">
{{ $insight->date->format('F d, Y') }}
125 changes: 86 additions & 39 deletions resources/views/front/pages/blog/index.blade.php
Original file line number Diff line number Diff line change
@@ -1,47 +1,94 @@
<x-page title="Blog" background="/backgrounds/blogs.jpg">
<!-- @todo replace background -->

@include('front.pages.blog.partials.menu')
<x-page
title="Insights"
background="/backgrounds/blog-index.png"
body-class="bg-oss-gray"
main-class="font-pt text-oss-royal-blue font-medium text-18 leading-140 antialiased"
>
<header class="wrapper-lg mt-12">
<x-headers.h1 class="text-right text-white">
Blog
</x-headers.h1>
</header>

@if($highlight)
<article class="wrapper-lg flex flex-col sm:flex-row gap-8 sm:gap-16 mt-8">
<a href="{{ route('blog.show', $highlight->slug) }}" class="flex-shrink-0">
@if ($highlight->header_image)
<img
src="{{ $highlight->header_image }}"
alt="{{ $highlight->title }}"
class="w-[220px] h-[220px] sm:w-[440px] sm:h-[440px] object-cover rounded-8"
>
@else
<div class="w-[220px] h-[220px] sm:w-[440px] sm:h-[440px] bg-oss-green-pale rounded-8"></div>
@endif
</a>
<div class="sm:pt-24 flex flex-col gap-6 sm:gap-9">
<p class="flex items-center gap-3 text-sm">
<a href="{{ route('blog.show', $highlight->slug) }}" class="bg-oss-green-pale font-semibold rounded-8 px-2 py-1.5">
Latest post
</a>
<a href="{{ route('blog.show', $highlight->slug) }}">
<time datetime="{{ $highlight->date->format('Y-m-d') }}">
{{ $highlight->date->format('F d, Y') }}
</time>
</a>
</p>
<x-headers.h2>
<a href="{{ route('blog.show', $highlight->slug) }}" class="hover:text-oss-spatie-blue">
{{ $highlight->title }}
</a>
</x-headers.h2>
<div>
{!! $highlight->summary !!}
</div>
</div>
</article>
<hr class="sm:hidden mx-3 my-16 h-px bg-oss-gray-medium">
@endif

<section id="banner" class="banner" role="banner">
<div class="wrap">
<h1 class="banner-slogan">
Latest insights
<br>of the team
</h1>
<p class="banner-intro">
A collection of articles on our personal blogs
</p>
@if($posts->isNotEmpty())
<div class="wrapper-lg mt-12 sm:mt-16 lg:mt-32">
<div class="grid sm:grid-cols-[1fr,2fr] gap-8">
<h2 class="hidden sm:block text-24 font-bold pt-9">More posts</h2>
<div>
@foreach($posts as $post)
<x-blog.list-item :insight="$post" />
@if(!$loop->last)
<hr class="sm:hidden h-px bg-oss-gray-medium">
@endif
@endforeach
@if ($posts->hasMorePages())
<a href="{{ route('blog.all') }}" wire:navigate.hover class="flex w-full items-center justify-center py-6 text-blue bg-link-card-light border border-gray/25 rounded">
View more
</a>
@endif
</div>
</div>
</div>
</section>
@endif

<section class="section section-group">
<div class="wrap">
<div class="max-w-md grid gap-6">
@foreach ($posts as $post)
<p class="">
<a class="link link-black link-underline" href="{{ $post->url }}" target="_blank" rel="noreferrer noopener">
<span class="title-sm">{{ $post->title }}</span>
</a>
@if($post->short_summary)
<br />
<a class="link link-black no-underline" href="{{ $post->url }}" target="_blank" rel="noreferrer noopener">
{{ $post->short_summary }}
<div class="wrapper-lg my-16">
<livewire:newsletter />
</div>

@isset($externalFeedItems)
<div class="wrapper-lg mt-24 mb-20">
<div class="grid sm:grid-cols-[1fr,2fr] gap-8">
<h2 class="text-24 font-bold leading-snug text-center sm:text-left">From our team <br class="hidden sm:inline"> &&nbsp;products</h2>
<div class="pt-1.5 grid gap-8">
@foreach($externalFeedItems as $externalFeedItem)
@include('front.pages.blog.partials.externalFeedItem')
@endforeach
@if($externalFeedItems->hasMorePages())
<p class="pt-2">
<a href="{{ route('external-feed-items') }}" wire:navigate.hover class="flex w-full items-center justify-center py-4 text-blue bg-link-card-light border border-gray/25 rounded">
View more
</a>
@endif
<br />
<span class="text-xs text-gray">
{{ $post->created_at->format('M jS Y') }}
<span class="char-separator" >•</span>
<a class="link-underline link-blue" href="{{ $post->url }}" target="_blank" rel="noreferrer noopener">{{ $post->website }}</a>
</span>
</p>
@endforeach
</div>
<div class="mt-12">
{{ $posts->onEachSide(1)->links() }}
</p>
@endif
</div>
</div>
</div>
</section>
@endisset
</x-page>
34 changes: 0 additions & 34 deletions resources/views/front/pages/blog/music.blade.php

This file was deleted.

5 changes: 0 additions & 5 deletions resources/views/front/pages/blog/partials/menu.blade.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -77,7 +77,7 @@
<h2 class="text-24 font-bold text-center sm:text-left">Continue reading</h2>
<div class="sm:-mt-9">
@foreach($otherPosts as $otherPost)
<x-insights.list-item :insight="$otherPost" />
<x-blog.list-item :insight="$otherPost" />
@endforeach
</div>
</div>
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
</h1>
<div class="grid gap-8 pb-16">
@foreach($externalFeedItems as $externalFeedItem)
@include('front.pages.insights.partials.externalFeedItem')
@include('front.pages.blog.partials.externalFeedItem')
@endforeach
{{ $externalFeedItems->links() }}
</div>
47 changes: 20 additions & 27 deletions resources/views/front/pages/home/partials/news.blade.php
Original file line number Diff line number Diff line change
@@ -14,38 +14,31 @@
<h2 class="title-sm">
<a href={{route('blog')}}>News &amp; insights</a>
<span class="title-subtext text-pink-dark block">
of the team
from our blog, team, and products
</span>
</h2>


@foreach ($externalFeedItems->slice(0, 2) as $insight)
<p class="mt-4">
<a class="link link-black" href="{{ $insight->url }}" target="_blank"
rel="noreferrer noopener">{{ $insight->title }}</a>
<br>
<span class="text-xs text-gray">
{{ $insight->created_at->format('M jS Y') }}
<span class="char-separator">•</span>
<a class="link-underline link-blue" href="{{ $insight->url }}" target="_blank"
rel="noreferrer noopener">{{ $insight->website }}</a>
</span>
</p>
@endforeach
@include('front.pages.home.partials.newsItem', [
'url' => route('blog.show', $latestBlogPost->slug),
'title' => $latestBlogPost->title,
'date' => $latestBlogPost->date,
'website' => 'spatie.be',
])
@include('front.pages.home.partials.newsItem', [
'url' => $externalFeedItems->first()->url,
'title' => $externalFeedItems->first()->title,
'date' => $externalFeedItems->first()->created_at,
'website' => $externalFeedItems->first()->website,
])
</div>
<div class="sm:col-span-3 | line-l">
@foreach ($externalFeedItems->slice(2, 2) as $insight)
<p class="mt-4">
<a class="link link-black" href="{{ $insight->url }}" target="_blank"
rel="noreferrer noopener">{{ $insight->title }}</a>
<br>
<span class="text-xs text-gray">
{{ $insight->created_at->format('M jS Y') }}
<span class="char-separator">•</span>
<a class="link-underline link-blue" href="{{ $insight->url }}" target="_blank"
rel="noreferrer noopener">{{ $insight->website }}</a>
</span>
</p>
@foreach ($externalFeedItems->slice(1, 2) as $insight)
@include('front.pages.home.partials.newsItem', [
'url' => $insight->url,
'title' => $insight->title,
'date' => $insight->created_at,
'website' => $insight->website,
])
@endforeach
</div>
<div>
13 changes: 13 additions & 0 deletions resources/views/front/pages/home/partials/newsItem.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<p class="mt-4">
<a class="link link-black" href="{{ $url }}" @unless($website === 'spatie.be') target="_blank" rel="noreferrer noopener" @endunless>
{{ $title }}
</a>
<br>
<span class="text-xs text-gray">
{{ $date->format('M jS Y') }}
<span class="char-separator">•</span>
<a class="link-underline link-blue" href="{{ $url }}" @unless($website === 'spatie.be') target="_blank" rel="noreferrer noopener" @endunless>
{{ $website }}
</a>
</span>
</p>
94 changes: 0 additions & 94 deletions resources/views/front/pages/insights/index.blade.php

This file was deleted.

This file was deleted.

9 changes: 3 additions & 6 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -53,9 +53,9 @@

Route::feeds();

Route::get('insights', [BlogController::class, 'index'])->name('insights');
Route::get('insights/all', [BlogController::class, 'all'])->name('insights.all');
Route::get('insights/{slug}', [BlogController::class, 'detail'])->name('insights.show');
Route::get('blog', [BlogController::class, 'index'])->name('blog');
Route::get('blog/all', [BlogController::class, 'all'])->name('blog.all');
Route::get('blog/{slug}', [BlogController::class, 'detail'])->name('blog.show');
Route::get('team-products', ExternalFeedItemsController::class)->name('external-feed-items');

Route::redirect('/docs/products/ray', '/docs/ray');
@@ -178,9 +178,6 @@
Route::get('/guidelines', [GuidelinesController::class, 'index'])->name('guidelines');
Route::get('/guidelines/{page}', [GuidelinesController::class, 'show']);

Route::get('/blog', [BlogsController::class, 'index'])->name('blog');
Route::get('/blog/music', MusicController::class)->name('music');

Route::view('legal', 'front.pages.legal.index')->name('legal.index');
Route::view('privacy', 'front.pages.legal.privacy')->name('legal.privacy');
Route::view('disclaimer', 'front.pages.legal.disclaimer')->name('legal.disclaimer');

0 comments on commit db6ec33

Please sign in to comment.