-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4b5ab5
commit 93df8fd
Showing
14 changed files
with
299 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Spatie\ContentApi\ContentApi; | ||
use Spatie\ContentApi\Data\Post; | ||
use Spatie\Feed\FeedItem; | ||
|
||
class InsightsController | ||
{ | ||
public function index() | ||
{ | ||
$posts = ContentApi::getPosts('ray', request('page', 1), theme: 'nord'); | ||
|
||
if (request('page', 1)) { | ||
$firstPost = $posts->first(); | ||
unset($posts[0]); | ||
} | ||
|
||
return view('front.pages.insights.index', [ | ||
'posts' => $posts, | ||
'firstPost' => $firstPost ?? null, | ||
]); | ||
} | ||
|
||
public function detail(string $slug) | ||
{ | ||
$post = ContentApi::getPost('spatie', $slug, theme: 'nord'); | ||
|
||
if (! $post && is_numeric(explode('-', $slug)[0])) { | ||
$parts = explode('-', $slug); | ||
|
||
$parts = array_slice($parts, 1); | ||
|
||
return redirect(action([self::class, 'detail'], implode('-', $parts)), 301); | ||
} | ||
|
||
abort_if(is_null($post), 404); | ||
|
||
return view('front.pages.insights.show', [ | ||
'post' => $post, | ||
]); | ||
} | ||
|
||
public static function getFeedItems() | ||
{ | ||
return ContentApi::getPosts('spatie', 1, 10_000, theme: 'nord')->map(function (Post $post) { | ||
return FeedItem::create() | ||
->id($post->slug) | ||
->title($post->title) | ||
->summary($post->summary) | ||
->updated($post->updated_at) | ||
->link(action([self::class, 'detail'], $post->slug)) | ||
->authorName($post->authors->first()?->name); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace App\Livewire; | ||
|
||
use App\Actions\SubscribeUserToNewsletterAction; | ||
use App\Services\Mailcoach\MailcoachApi; | ||
use Livewire\Component; | ||
|
||
class NewsletterComponent extends Component | ||
{ | ||
public string $email = ''; | ||
|
||
public bool $submitted = false; | ||
|
||
public function render() | ||
{ | ||
return view('livewire.newsletter-component'); | ||
} | ||
|
||
public function subscribe() | ||
{ | ||
//TODO: make this work | ||
$this->validate([ | ||
'email' => 'required|email', | ||
]); | ||
|
||
$mailcoach = app(MailcoachApi::class); | ||
|
||
$subscriber = $mailcoach->subscribe(strtolower($this->email), skipConfirmation: true); | ||
$subscriber->addTags('spatie-newsletter'); | ||
|
||
$this->submitted = true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<x-page title="Blog" background="/backgrounds/blogs.jpg"> | ||
<!-- @todo replace background --> | ||
|
||
<section id="banner" class="banner" role="banner"> | ||
Insights | ||
</section> | ||
|
||
@if($firstPost) | ||
@include('front.pages.insights.partials.firstPostListItem', ['post' => $firstPost]) | ||
@endif | ||
|
||
<h2> | ||
More insights | ||
</h2> | ||
|
||
<section class="section section-group"> | ||
<div class="wrap"> | ||
<div class="max-w-md grid gap-6"> | ||
@foreach($posts as $post) | ||
@include('front.pages.insights.partials.postListItem') | ||
@endforeach | ||
</div> | ||
<div class="mt-12"> | ||
{{ $posts->onEachSide(1)->links() }} | ||
</div> | ||
</div> | ||
</section> | ||
|
||
<livewire:newsletter /> | ||
</x-page> |
12 changes: 12 additions & 0 deletions
12
resources/views/front/pages/insights/partials/firstPostListItem.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<article> | ||
Last article | ||
|
||
<div> | ||
<time datetime="{{ $post->date->format('Y-m-d') }}">{{ $post->date->format('d F Y') }}</time> | ||
</div> | ||
|
||
{{ $post->title }} | ||
|
||
<p>{{ htmlspecialchars_decode(strip_tags($post->summary)) }}</p> | ||
|
||
</article> |
23 changes: 23 additions & 0 deletions
23
resources/views/front/pages/insights/partials/newsletter.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<div> | ||
<div> | ||
Get the latest from Spatie | ||
</div> | ||
|
||
<div> | ||
<div>Logo</div> | ||
<div>Powered by <a href="https://mailcoach.app">Mailcoach</a>, powerful email marketing tools to effortlessly grow, connect and convert.</div> | ||
</div> | ||
|
||
<div> | ||
<div> | ||
<form> | ||
<input type="email" placeholder="Your email address"> | ||
<button>Subscribe</button> | ||
</form> | ||
</div> | ||
<div> | ||
Sign up for occasional emails on Spatie products and promotions. | ||
By submitting this from, you acknowledge our [Privacy Policy]({{ route('legal.privacy') }}). | ||
</div> | ||
</div> | ||
</div> |
16 changes: 16 additions & 0 deletions
16
resources/views/front/pages/insights/partials/postListItem.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<article> | ||
<div> | ||
<h3> | ||
<a href="{{ route('insights.show', $post->slug) }}"> | ||
<span></span> | ||
{{ $post->title }} | ||
</a> | ||
</h3> | ||
<p>{{ htmlspecialchars_decode(strip_tags($post->summary)) }}</p> | ||
</div> | ||
@isset($post->date) | ||
<div> | ||
<time datetime="{{ $post->date->format('Y-m-d') }}">{{ $post->date->format('d F Y') }}</time> | ||
</div> | ||
@endisset | ||
</article> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<div> | ||
<div> | ||
Get the latest from Spatie | ||
</div> | ||
|
||
<div> | ||
<div>Logo</div> | ||
<div>Powered by <a href="https://mailcoach.app">Mailcoach</a>, powerful email marketing tools to effortlessly | ||
grow, connect and convert. | ||
</div> | ||
</div> | ||
|
||
@if($submitted) | ||
<div> | ||
<div> | ||
<h2>Thank you for subscribing!</h2> | ||
<p>You'll receive a confirmation email shortly.</p> | ||
</div> | ||
</div> | ||
@else | ||
<div> | ||
<div> | ||
<div> | ||
<input name="email" wire:model="email" type="email" placeholder="Your email address"> | ||
@error('email') | ||
<div>{{ $message }}</div> | ||
@enderror | ||
|
||
<button wire:click="subscribe">Subscribe</button> | ||
</div> | ||
</div> | ||
<div> | ||
Sign up for occasional emails on Spatie products and promotions. | ||
By submitting this from, you acknowledge our [Privacy Policy]({{ route('legal.privacy') }}). | ||
</div> | ||
</div> | ||
@endif | ||
</div> |
Oops, something went wrong.