diff --git a/app/Filament/Resources/StoryResource.php b/app/Filament/Resources/StoryResource.php index e8782fe..7232d11 100644 --- a/app/Filament/Resources/StoryResource.php +++ b/app/Filament/Resources/StoryResource.php @@ -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') @@ -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), ]); } diff --git a/app/Http/Controllers/StoryController.php b/app/Http/Controllers/StoryController.php index 0cc3559..b98994a 100644 --- a/app/Http/Controllers/StoryController.php +++ b/app/Http/Controllers/StoryController.php @@ -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(), ]); @@ -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, ]); diff --git a/app/Models/Story.php b/app/Models/Story.php index 509fecd..7d48921 100644 --- a/app/Models/Story.php +++ b/app/Models/Story.php @@ -15,6 +15,7 @@ class Story extends Model 'headline', 'slug', 'summary', + 'description', 'source', 'vendor_id', 'mood', diff --git a/composer.json b/composer.json index ec2dbb5..4ee6963 100644 --- a/composer.json +++ b/composer.json @@ -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" }, diff --git a/composer.lock b/composer.lock index 340f273..3301c75 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ac03fd8a3920810d1892f3785ac09762", + "content-hash": "f9bdee0eb0ae9313b0586d3df77b28b1", "packages": [ { "name": "anourvalar/eloquent-serialize", @@ -1958,6 +1958,86 @@ ], "time": "2023-12-03T19:50:20+00:00" }, + { + "name": "honeystone/laravel-seo", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/Honeystone/laravel-seo.git", + "reference": "bc7ad420f741e316f2f07ccdcf808892ff9d60d7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Honeystone/laravel-seo/zipball/bc7ad420f741e316f2f07ccdcf808892ff9d60d7", + "reference": "bc7ad420f741e316f2f07ccdcf808892ff9d60d7", + "shasum": "" + }, + "require": { + "ext-zip": "*", + "illuminate/contracts": "^10.0|^11.0", + "laravel/prompts": "^0.1.25", + "php": "^8.2", + "spatie/laravel-package-tools": "^1.16.4" + }, + "require-dev": { + "nunomaduro/collision": "^8.0", + "nunomaduro/larastan": "^2.9", + "nunomaduro/phpinsights": "^2.11", + "orchestra/testbench": "^9.2", + "pestphp/pest": "^2.0", + "pestphp/pest-plugin-laravel": "^2.4", + "phpstan/extension-installer": "^1.4", + "phpstan/phpstan-deprecation-rules": "^1.2", + "phpstan/phpstan-phpunit": "^1.4", + "phpunit/phpunit": "^10.0", + "spatie/laravel-ray": "^1.37", + "spatie/schema-org": "^3.23" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Honeystone\\Seo\\Providers\\SeoServiceProvider" + ] + } + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Honeystone\\Seo\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "George Palmer", + "email": "george@honeystone.com", + "role": "Developer" + } + ], + "description": "SEO metadata and JSON-LD package for Laravel.", + "homepage": "https://honeystone.com", + "keywords": [ + "JSON-LD", + "favicons", + "honeystone", + "laravel", + "metadata", + "opengraph", + "seo", + "twitter" + ], + "support": { + "issues": "https://github.com/Honeystone/laravel-seo/issues", + "source": "https://github.com/Honeystone/laravel-seo/tree/1.3.1" + }, + "time": "2024-08-22T17:35:10+00:00" + }, { "name": "kirschbaum-development/eloquent-power-joins", "version": "3.5.7", diff --git a/database/migrations/2024_08_22_195610_alter_stories_add_meta_description_column.php b/database/migrations/2024_08_22_195610_alter_stories_add_meta_description_column.php new file mode 100644 index 0000000..bc6d92b --- /dev/null +++ b/database/migrations/2024_08_22_195610_alter_stories_add_meta_description_column.php @@ -0,0 +1,28 @@ +string('meta_description')->default('')->nullable(false); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('stories', function (Blueprint $table) { + $table->dropColumn('meta_description'); + }); + } +}; diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 4b47ec1..97bc7fa 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -18,8 +18,9 @@ function gtag(){dataLayer.push(arguments);} - {{ $vendor ?: 'Vendor' }} Stories - + + @metadata + @vite(['resources/css/app.css', 'resources/js/app.js']) @@ -34,7 +35,7 @@ function gtag(){dataLayer.push(arguments);}

{{ Str::ucfirst($mood) }} {{ $vendor }} Stories

-

Follow us for the latest updates and sometimes happy, sometimes sad, sometimes neutral stories from {{ $vendor ? $vendor : 'different vendors' }}.

+

Follow us for the latest updates and sometimes happy, sometimes sad, sometimes neutral stories from the real people interating with big corporations.