Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
feat: microdata
Browse files Browse the repository at this point in the history
  • Loading branch information
bohdan-shulha committed Aug 22, 2024
1 parent 36b76be commit f856115
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 6 deletions.
7 changes: 5 additions & 2 deletions app/Filament/Resources/StoryResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static function form(Form $form): Form
->schema([
Forms\Components\TextInput::make('headline')->required()->afterStateUpdated(fn ($state, $set) => $set('slug', Str::slug($state.'-'.now()->format('Y-m-d'))))->lazy(),
Forms\Components\TextInput::make('slug')->readOnly()->required(),
Forms\Components\Textarea::make('meta_description')->required(),
Forms\Components\RichEditor::make('summary')->required(),
Forms\Components\Group::make([
Forms\Components\Select::make('vendor_id')
Expand All @@ -34,8 +35,10 @@ public static function form(Form $form): Form
->options(['positive' => '😊 Positive', 'neutral' => '😐 Neutral', 'negative' => '😠 Negative'])
->required(),
])->columns(2),
Forms\Components\TextInput::make('source')->url()->required(),
Forms\Components\DatePicker::make('published_at')->time()->afterStateUpdated(fn ($state, $get, $set) => $set('slug', Str::slug($get('headline').'-'.\Carbon\Carbon::parse($state)->format('Y-m-d'))))->lazy(),
Forms\Components\Group::make([
Forms\Components\TextInput::make('source')->url()->required(),
Forms\Components\DatePicker::make('published_at')->time()->afterStateUpdated(fn ($state, $get, $set) => $set('slug', Str::slug($get('headline').'-'.\Carbon\Carbon::parse($state)->format('Y-m-d'))))->lazy(),
])->columns(2),
]);
}

Expand Down
8 changes: 8 additions & 0 deletions app/Http/Controllers/StoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class StoryController extends Controller
*/
public function index()
{
seo()
->title("All Stories")
->description("Stay tuned for the latest updates and a mix of uplifting, heartwarming, and thought-provoking stories from the real people.");

return view('stories.index', [
'stories' => Story::published()->orderBy('published_at', 'desc')->get(),
]);
Expand All @@ -21,6 +25,10 @@ public function index()
*/
public function show(Story $story)
{
seo()
->title($story->headline)
->description($story->meta_description);

return view('stories.show', [
'story' => $story,
]);
Expand Down
1 change: 1 addition & 0 deletions app/Models/Story.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Story extends Model
'headline',
'slug',
'summary',
'description',
'source',
'vendor_id',
'mood',
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"php": "^8.2",
"filament/filament": "^3.2",
"filament/forms": "^3.2",
"honeystone/laravel-seo": "^1.3",
"laravel/framework": "^11.9",
"laravel/tinker": "^2.9"
},
Expand Down
82 changes: 81 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('stories', function (Blueprint $table) {
$table->string('meta_description')->default('')->nullable(false);
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('stories', function (Blueprint $table) {
$table->dropColumn('meta_description');
});
}
};
7 changes: 4 additions & 3 deletions resources/views/layouts/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ function gtag(){dataLayer.push(arguments);}

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<title>{{ $vendor ?: 'Vendor' }} Stories</title>
<meta name="description" content="Stay tuned for the latest updates and a mix of uplifting, heartwarming, and thought-provoking stories from {{ $vendor ? $vendor : 'various vendors' }}.">

@metadata

@vite(['resources/css/app.css', 'resources/js/app.js'])
</head>
<body class="flex justify-center bg-gradient-to-r from-lightblue-200 to-lightgray-300">
Expand All @@ -34,7 +35,7 @@ function gtag(){dataLayer.push(arguments);}
<div class="min-w-[600px] p-4 md:p-4 lg:p-4 bg-white bg-opacity-50 rounded-lg shadow-lg">
<div>
<h1 class="text-3xl font-bold mb-4 text-gray-600">{{ Str::ucfirst($mood) }} {{ $vendor }} Stories</h1>
<p class="text-lg text-gray-700 text-balance">Follow us for the latest updates and sometimes happy, sometimes sad, sometimes neutral stories from {{ $vendor ? $vendor : 'different vendors' }}.</p>
<p class="text-lg text-gray-700 text-balance">Follow us for the latest updates and sometimes happy, sometimes sad, sometimes neutral stories from the real people interating with big corporations.</p>
</div>
</div>
<div class="content p-4 md:p-6 lg:p-8 ">
Expand Down

0 comments on commit f856115

Please sign in to comment.