Caching and og title

This commit is contained in:
2021-01-11 19:36:39 +05:00
parent 0d78b68804
commit 09e544d361
4 changed files with 28 additions and 4 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use App\Article;
class NameSpaceController extends Controller
@@ -17,11 +18,16 @@ class NameSpaceController extends Controller
if (!array_key_exists($namespace, config('karudhaas.topic_filters'))) return redirect('/namespaces');
$options = config("karudhaas.topic_filters." . $namespace);
$articles = Cache::remember("articles.$namespace", 600, function () use ($options) {
return Article::with('source')->whereHas('topics', function ($q) use ($options) {
$q->whereIn('slug', $options["keys"]);
})->latest('published_date')->limit(8)->get();
});
return view('namespaces.show', [
'options' => $options,
'articles' => Article::with('source')->whereHas('topics', function ($q) use ($options) {
$q->whereIn('slug', $options["keys"]);
})->latest('published_date')->paginate(8)
'articles' => $articles
]);
}
}

View File

@@ -6,6 +6,7 @@ return [
"covid19" => [
"dv_name" => "ކޮރޯނާ ވައިރަސް",
"en_name" => "coronavirus",
"description" => "ކޮރޯނާ ވައިރަހާއި ބެހޭ ޙަބަރުތަކުގެ އެންމެފަހުގެ އަޕްޑޭޓް.",
"keys" => ["covid19", "covid-19", "corona_virus", "covid_19", "coronavirus"],
"color" => "red"
@@ -14,6 +15,7 @@ return [
"sports" => [
"dv_name" => "ކުޅިވަރު",
"en_name" => "sports",
"description" => "ކުޅިވަރުގެ ތަފާތު ޙަބަރުތަށް",
"keys" => [
"football", "sport", "kulhivaru", "maldives_national_football_tea", "football_association_of_maldiv", "local_sports", "spanish_league",
@@ -25,6 +27,7 @@ return [
"business" => [
"dv_name" => "ވިޔަފާރި",
"en_name" => "business",
"description" => "ފިޔަފާރިއާ ބެހޭ އެންމެ ފަހުގެ ޙަބަރުތަށް",
"keys" => [
"tourism", "sme_loan","sme_bank","public_companies","mtcc","tourists","world_tourism_day_","mtcc_shares","google","guest_house","fish_products","tax", "business", "dhiraagu",

View File

@@ -6,7 +6,7 @@
<meta name="description" content="Discover Stories,Daily news and inspiration for maldivian readers." />
<meta name=" twitter:title" content="{{$article->meta['title']}}" />
<meta name="twitter:description" content="Discover Stories,Daily news and inspiration for maldivian readers." />
<meta name="twitter:site" content="https://baraveli-news.baraveli.xyz/" />
<meta name="twitter:site" content="https://karudhaas.net/" />
<meta name="twitter:image" content="{{$article->featured_image}}">
<meta property="og:locale" content="mv" />
<meta property="og:type" content="website" />

View File

@@ -1,5 +1,20 @@
<x-layout>
<x-slot name="meta">
<title>{{ucfirst($options['en_name'])}} | Karudhaas</title>
<meta name="description" content="Discover Stories,Daily news and inspiration for maldivian readers." />
<meta name=" twitter:title" content="{{$options['en_name']}}" />
<meta name="twitter:description" content="Discover Stories,Daily news and inspiration for maldivian readers." />
<meta name="twitter:site" content="https://karudhaas.net/" />
<meta property="og:locale" content="mv" />
<meta property="og:type" content="website" />
<meta property="og:title" content="{{$options['en_name']}}">
<meta property="og:description" content="Discover Stories,Daily news and inspiration for maldivian readers." />
<meta property="og:url" content="https://karudhaas.net/" />
<meta property="og:site_name" content="karudhaas.net" />
</x-slot>
<div class="mb-10">
<div class="flex flex-col items-center">
<h3 class="text-gray-800 text-3xl text-center mt-5 mb-2 mr-3 MvAamu" style="font-weight: 100;">