Skip to content

Commit

Permalink
Create blog render files
Browse files Browse the repository at this point in the history
  • Loading branch information
Raccoon254 committed Aug 9, 2024
1 parent bb26bd8 commit de7a6d4
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/Livewire/BlogMaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function saveBlog(): mixed
return redirect()->route('blog.create' )->with('error', 'Failed to create blog' . $e->getMessage());
}

return redirect()->route('blogs.show', $blog->slug);
return redirect()->route('blog.show', $blog->slug);
}

public function render(): View
Expand Down
13 changes: 13 additions & 0 deletions app/Livewire/BlogRenderer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App\Livewire;

use Livewire\Component;

class BlogRenderer extends Component
{
public function render()
{
return view('livewire.blog-renderer');
}
}
2 changes: 1 addition & 1 deletion resources/views/blogs/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
const toolbarOptions = [
['bold', 'italic', 'underline', 'strike'], // toggled buttons
['blockquote', 'code-block'],
['blockquote', 'image', 'link'],
[{ 'header': 1 }, { 'header': 2 }, { 'header': 3 }], // custom button values
[{ 'list': 'ordered'}, { 'list': 'bullet' }, { 'list': 'check' }],
Expand Down
25 changes: 25 additions & 0 deletions resources/views/blogs/show.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@extends('layouts.app')

@section('content')
<div class="container mx-auto py-8">
<div class="bg-white shadow-lg rounded-lg">
<div class="p-6">
<h1 class="text-3xl font-bold text-gray-800">{{ $blog->title }}</h1>
<p class="text-gray-600 text-sm mt-2">by {{ $blog->user->name }} on {{ $blog->created_at->format('F j, Y') }}</p>
<div class="mt-4 text-gray-700 leading-relaxed">
{!! $blog->content !!}
</div>
@if ($blog->images->isNotEmpty())
<div class="mt-6">
<h2 class="text-2xl font-bold text-gray-800">Images</h2>
<div class="grid grid-cols-2 gap-4 mt-4">
@foreach ($blog->images as $image)
<img src="{{ Storage::url($image->path) }}" alt="{{ $image->alt }}" class="rounded-lg">
@endforeach
</div>
</div>
@endif
</div>
</div>
</div>
@endsection
3 changes: 3 additions & 0 deletions resources/views/livewire/blog-renderer.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div>
{{-- If you look to others for fulfillment, you will never truly be fulfilled. --}}
</div>
6 changes: 5 additions & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use App\Livewire\UserShow;
use App\Livewire\VerifyOrderPayment;
use App\Livewire\VerifyPayments;
use App\Models\Blog;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\StaticPageController;
use App\Http\Controllers\PagesController;
Expand Down Expand Up @@ -71,6 +72,9 @@
Route::post('/newsletter/subscribe', [PagesController::class, 'subscribe'])->name('newsletter.subscribe');

Route::get('/blog', [PagesController::class, 'blog'])->name('blog');
Route::get('/blog/{blog}', [PagesController::class, 'blog_show'])->name('blog.show');
Route::get('/blogs/{blog:slug}', function (Blog $blog) {
return view('blogs.show', compact('blog'));
})->name('blog.show');


require __DIR__.'/auth.php';

0 comments on commit de7a6d4

Please sign in to comment.