Skip to content

Commit

Permalink
Add keywords to PostResource and update meta tags in Post.vue for imp…
Browse files Browse the repository at this point in the history
…roved SEO; streamline sitemap route
  • Loading branch information
abdessamadbettal committed Dec 14, 2024
1 parent 7f3d806 commit c7431be
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
1 change: 1 addition & 0 deletions app/Http/Resources/PostResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function toArray(Request $request): array
'image' => $this->getFirstMediaUrl('thumbnail') ?? null,
'content' => MarkdownHelper::convertToHtml($this->content),
'excerpt' => Str::limit($this->content, $excerptLength, '...'),
'keywords' => $this->tags->pluck('name')->implode(', '),
'author' => new UserResource($this->author),
'category' => new CategoryResource($this->category),
'is_published' => $this->is_published,
Expand Down
30 changes: 13 additions & 17 deletions resources/js/Pages/Post/Post.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,24 @@ const post = computed(() => props.post.data);

<template>

<Head>
<Head>
<title>{{ post?.name }}</title>
<meta name="description" content="{{ post?.excerpt }}">
<meta property="og:title" content="{{ post?.name }}">
<meta property="og:description" content="{{ post?.excerpt }}">
<meta property="og:image" content="{{ post?.image }}">
<meta property="og:url" content="{{ window.location.href }}">
<meta name="description" :content="post?.excerpt">
<meta name="keywords" :content="post?.keywords">
<meta property="og:title" :content="post?.name">
<meta property="og:description" :content="post?.excerpt">
<meta property="og:image" :content="post?.image">
<meta property="og:url" :content="`/posts/${post?.slug}`">
<meta property="og:type" content="article">
<meta property="article:published_time" content="{{ post?.created_at }}">
<meta property="article:author" content="{{ post?.author?.name }}">
<meta property="article:section" content="{{ post?.category?.name }}">
<meta property="article:tag" content="{{ post?.tags }}">
<meta property="article:modified_time" content="{{ post?.updated_at }}">
<meta property="article:published_time" content="{{ post?.created_at }}">
<meta property="article:author" content="{{ post?.author?.name }}">
<meta property="article:section" content="{{ post?.category?.name }}">
<meta property="article:tag" content="{{ post?.tags }}">
<meta property="article:modified_time" content="{{ post?.updated_at }}">
<meta property="article:published_time" :content="post?.created_at">
<meta property="article:author" :content="post?.author?.name">
<meta property="article:section" :content="post?.category?.name">
<meta property="article:tag" :content="post?.keywords">
<meta property="article:modified_time" :content="post?.updated_at">
</Head>

<section
class="relative table w-full items-center py-36 bg-[url('../../assets/images/bg/cta.jpg')] bg-top bg-no-repeat bg-cover">
class="relative table w-full items-center py-12">
<div class="absolute inset-0 bg-gradient-to-b from-slate-900/60 via-slate-900/80 to-slate-900"></div>
<div class="container relative">
<div class="grid grid-cols-1 pb-8 text-center mt-10">
Expand Down
2 changes: 1 addition & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
use App\Http\Controllers\ProfileController;
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;


Route::get('/sitemap.xml', function () {
return \Spatie\Sitemap\Sitemap::create()
->add(\Spatie\Sitemap\Tags\Url::create('/'))
->add(\Spatie\Sitemap\Tags\Url::create('/about'))
->writeToFile(public_path('sitemap.xml'));
});

Route::group(
[
'prefix' => LaravelLocalization::setLocale(),
Expand Down

0 comments on commit c7431be

Please sign in to comment.