Update (layout): add favicon, improve home pages, add noindex if page is empty

This commit is contained in:
2023-08-02 01:16:55 +08:00
parent 2ddc91a0c6
commit 6a37294e9b
11 changed files with 143 additions and 103 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -63,6 +63,10 @@ public function country(Request $request, $country)
->take(10) ->take(10)
->get(); ->get();
if ($latest_posts->count() <= 0) {
SEOMeta::setRobots('noindex');
}
SEOTools::metatags(); SEOTools::metatags();
SEOTools::twitter(); SEOTools::twitter();
SEOTools::opengraph(); SEOTools::opengraph();
@@ -94,6 +98,8 @@ public function countryCategory(Request $request, $country, $category)
abort(404); abort(404);
} }
$request->session()->put('view_country_locale', $country_locale);
$latest_posts = Post::with('post_categories')->select('posts.*') $latest_posts = Post::with('post_categories')->select('posts.*')
->join('post_categories', 'posts.id', '=', 'post_categories.post_id') ->join('post_categories', 'posts.id', '=', 'post_categories.post_id')
->join('categories', 'post_categories.category_id', '=', 'categories.id') ->join('categories', 'post_categories.category_id', '=', 'categories.id')
@@ -106,6 +112,10 @@ public function countryCategory(Request $request, $country, $category)
->distinct() ->distinct()
->paginate(15); ->paginate(15);
if ($latest_posts->count() <= 0) {
SEOMeta::setRobots('noindex');
}
SEOTools::metatags(); SEOTools::metatags();
SEOTools::twitter(); SEOTools::twitter();
SEOTools::opengraph(); SEOTools::opengraph();
@@ -126,6 +136,8 @@ public function all(Request $request, $country)
{ {
$country_locale = CountryLocale::where('slug', $country)->first(); $country_locale = CountryLocale::where('slug', $country)->first();
$request->session()->put('view_country_locale', $country_locale);
$latest_posts = Post::with('post_categories')->select('posts.*') $latest_posts = Post::with('post_categories')->select('posts.*')
->join('post_categories', 'posts.id', '=', 'post_categories.post_id') ->join('post_categories', 'posts.id', '=', 'post_categories.post_id')
->join('categories', 'post_categories.category_id', '=', 'categories.id') ->join('categories', 'post_categories.category_id', '=', 'categories.id')
@@ -137,6 +149,10 @@ public function all(Request $request, $country)
->distinct() ->distinct()
->paginate(15); ->paginate(15);
if ($latest_posts->count() <= 0) {
SEOMeta::setRobots('noindex');
}
SEOTools::metatags(); SEOTools::metatags();
SEOTools::twitter(); SEOTools::twitter();
SEOTools::opengraph(); SEOTools::opengraph();
@@ -157,6 +173,8 @@ public function post(Request $request, $country, $post_slug)
if (! is_null($post)) { if (! is_null($post)) {
$request->session()->put('view_country_locale', $post->post_category->category->country_locale);
SEOMeta::setTitle($post->title); SEOMeta::setTitle($post->title);
SEOMeta::setDescription($post->excerpt); SEOMeta::setDescription($post->excerpt);
SEOMeta::addMeta('article:published_time', $post->publish_date, 'property'); SEOMeta::addMeta('article:published_time', $post->publish_date, 'property');

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

BIN
public/apple-touch-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
public/favicon-16x16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 630 B

BIN
public/favicon-32x32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 15 KiB

1
public/site.webmanifest Normal file
View File

@@ -0,0 +1 @@
{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}

View File

@@ -11,133 +11,148 @@
</div> </div>
</div> </div>
</div> </div>
<div class="container-fluid py-4 bg-dark text-light"> @if ($featured_posts->count() > 0)
<div class="container"> <div class="container-fluid py-4 bg-dark text-light">
<h3 class="h4 fw-bold text-center mb-3">Featured Articles</h3> <div class="container">
<div class="row g-3 justify-content-center"> <h3 class="h4 fw-bold text-center mb-3">Featured Articles</h3>
@foreach ($featured_posts as $post) <div class="row g-3 justify-content-center">
<div class="col-12 col-xl-3"> @foreach ($featured_posts as $post)
<div class="col-12 col-xl-3">
<div class="card shadow-sm" style="height:100%;"> <div class="card shadow-sm" style="height:100%;">
<a href="{{ route('home.country.post', ['country' => $country_locale->country_iso, 'post_slug' => $post->slug]) }}" <a href="{{ route('home.country.post', ['country' => $country_locale->country_iso, 'post_slug' => $post->slug]) }}"
class="text-decoration-none"> class="text-decoration-none">
<div class="card-img-top ratio ratio-16x9"> <div class="card-img-top ratio ratio-16x9">
<div class="lqip-loader"> <div class="lqip-loader">
<!-- Use the LQIP image with the appropriate URL --> <!-- Use the LQIP image with the appropriate URL -->
<img src="{{ $post->featured_image }}" alt="Photo of {{ $post->name }}"> <img src="{{ $post->featured_image }}" alt="Photo of {{ $post->name }}">
<!-- Use the final JPEG image with the appropriate URL -->
<img class="lqip-frozen" src="{{ $post->featured_image_lqip }}"
alt="Placeholder image of {{ $post->name }}">
</div>
<!-- Use the final JPEG image with the appropriate URL -->
<img class="lqip-frozen" src="{{ $post->featured_image_lqip }}"
alt="Placeholder image of {{ $post->name }}">
</div> </div>
</a>
</div> <div class="card-body d-flex justify-content-between flex-column">
</a>
<div class="card-body d-flex justify-content-between flex-column"> <div class="mb-2">
<div class="mb-2"> <p class="card-text fw-bold">
<a href="{{ route('home.country.post', ['country' => $country_locale->country_iso, 'post_slug' => $post->slug]) }}"
<p class="card-text fw-bold"> class="text-decoration-none">{{ $post->title }}</a>
<a href="{{ route('home.country.post', ['country' => $country_locale->country_iso, 'post_slug' => $post->slug]) }}" </p>
class="text-decoration-none">{{ $post->title }}</a> </div>
</p> <div>
</div> <p class="card-text mb-0">
<div> <small>in </small>
<p class="card-text mb-0"> @foreach ($post->post_categories as $post_category)
<small>in </small> <small><a class="text-decoration-none"
@foreach ($post->post_categories as $post_category) href="{{ route('home.country.category', ['country' => $country_locale->country_iso, 'category' => $post_category->category->slug]) }}">{{ $post_category->category->name }}</a>
<small><a class="text-decoration-none" </small>
href="{{ route('home.country.category', ['country' => $country_locale->country_iso, 'category' => $post_category->category->slug]) }}">{{ $post_category->category->name }}</a> @if (!$loop->last)
</small> ,
@if (!$loop->last) @endif
, @endforeach
@endif {{-- <small class="text-body-secondary ms-2">3 min read</small> --}}
@endforeach </p>
{{-- <small class="text-body-secondary ms-2">3 min read</small> --}} <div class="d-flex justify-content-between align-items-center">
</p> <small
<div class="d-flex justify-content-between align-items-center"> class="text-body-secondary">{{ $post->publish_date->format('j F Y') }}</small>
<small {{-- <small class="text-body-secondary">9 min read</small> --}}
class="text-body-secondary">{{ $post->publish_date->format('j F Y') }}</small> </div>
{{-- <small class="text-body-secondary">9 min read</small> --}}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
@endforeach
</div> </div>
@endforeach
</div> </div>
</div> </div>
</div> @endif
<div class="container-fluid py-4">
<div class="container">
<div class="row justify-content-center">
<div class="col col-md-12 col-lg-12 col-xl-11 col-xxl-9">
<h3 class="h4 fw-bold text-center mb-3">What's New in
{{ get_country_name_by_iso($country_locale->country_iso) }}</h3>
<div class="row g-3">
@foreach ($latest_posts as $post)
<div class="col-lg-6">
<div class="card" style="height:100%;"> @if (count($latest_posts) > 0)
<div class="row g-0"> <div class="container-fluid py-4">
<div class="col-md-5"> <div class="container">
<a href="{{ route('home.country.post', ['country' => $country_locale->country_iso, 'post_slug' => $post->slug]) }}" <div class="row justify-content-center">
class="text-decoration-none"> <div class="col col-md-12 col-lg-12 col-xl-11 col-xxl-9">
<div class="img-fluid rounded-start ratio ratio-16x9"> <h3 class="h4 fw-bold text-center mb-3">What's New in
<div class="lqip-loader"> {{ get_country_name_by_iso($country_locale->country_iso) }}</h3>
<!-- Use the LQIP image with the appropriate URL --> <div class="row g-3">
<img src="{{ $post->featured_image }}" @foreach ($latest_posts as $post)
alt="Photo of {{ $post->name }}"> <div class="col-lg-6">
<!-- Use the final JPEG image with the appropriate URL --> <div class="card" style="height:100%;">
<img class="lqip-frozen" src="{{ $post->featured_image_lqip }}" <div class="row g-0">
alt="Placeholder image of {{ $post->name }}"> <div class="col-md-5">
<a href="{{ route('home.country.post', ['country' => $country_locale->country_iso, 'post_slug' => $post->slug]) }}"
class="text-decoration-none">
<div class="img-fluid rounded-start ratio ratio-16x9">
<div class="lqip-loader">
<!-- Use the LQIP image with the appropriate URL -->
<img src="{{ $post->featured_image }}"
alt="Photo of {{ $post->name }}">
<!-- Use the final JPEG image with the appropriate URL -->
<img class="lqip-frozen" src="{{ $post->featured_image_lqip }}"
alt="Placeholder image of {{ $post->name }}">
</div>
</div>
</a>
</div>
<div class="col-md-7">
<div class="card-body d-flex justify-content-between flex-column"
style="height:100%;">
<div>
<a href="{{ route('home.country.post', ['country' => $country_locale->country_iso, 'post_slug' => $post->slug]) }}"
class="text-decoration-none">
<p class="card-title fw-bold">{{ $post->title }}</p>
</a>
</div>
<div class="d-flex justify-content-between align-items-center">
<p class="card-text mb-0">
<small>in </small>
@foreach ($post->post_categories as $post_category)
<small><a class="text-decoration-none"
href="{{ route('home.country.category', ['country' => $country_locale->country_iso, 'category' => $post_category->category->slug]) }}">{{ $post_category->category->name }}</a>
</small>
@if (!$loop->last)
,
@endif
@endforeach
{{-- <small class="text-body-secondary ms-2">3 min read</small> --}}
</p>
<small
class="text-body-secondary">{{ $post->publish_date->format('j F Y') }}</small>
</div> </div>
</div>
</a>
</div>
<div class="col-md-7">
<div class="card-body d-flex justify-content-between flex-column"
style="height:100%;">
<div>
<a href="{{ route('home.country.post', ['country' => $country_locale->country_iso, 'post_slug' => $post->slug]) }}"
class="text-decoration-none">
<p class="card-title fw-bold">{{ $post->title }}</p>
</a>
</div>
<div class="d-flex justify-content-between align-items-center">
<p class="card-text mb-0">
<small>in </small>
@foreach ($post->post_categories as $post_category)
<small><a class="text-decoration-none"
href="{{ route('home.country.category', ['country' => $country_locale->country_iso, 'category' => $post_category->category->slug]) }}">{{ $post_category->category->name }}</a>
</small>
@if (!$loop->last)
,
@endif
@endforeach
{{-- <small class="text-body-secondary ms-2">3 min read</small> --}}
</p>
<small
class="text-body-secondary">{{ $post->publish_date->format('j F Y') }}</small>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> @endforeach
@endforeach
</div> </div>
<div class="text-center py-3"> <div class="text-center py-3">
<a href="{{ route('home.country.posts', ['country' => $country_locale->country_iso]) }}" @if ($country_locale->country_iso != '*')
class="btn btn-primary">All News & Updates</a> <a href="{{ route('home.country.posts', ['country' => $country_locale->country_iso]) }}"
class="btn btn-primary">All News & Updates</a>
@else
<a href="{{ route('home.country.posts', ['country' => 'world']) }}"
class="btn btn-primary">All News & Updates</a>
@endif
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> @else
<div class="container text-center pb-5">
Oops! Nothing much here yet. Stay tuned!
</div>
@endif
@endsection @endsection

View File

@@ -14,6 +14,12 @@
<meta name="csrf-token" content="{{ csrf_token() }}"> <meta name="csrf-token" content="{{ csrf_token() }}">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
<link rel="manifest" href="site.webmanifest">
@vite('resources/sass/front-app.scss') @vite('resources/sass/front-app.scss')
<!-- Custom styles for this Page--> <!-- Custom styles for this Page-->