Skip to content

Commit d306760

Browse files
committed
base layout improvements
1 parent 62011f0 commit d306760

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

resources/views/components/layouts/base.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1">
66
<meta name="csrf-token" content="{{ csrf_token() }}">
77

8-
<title>{{ \Artesaos\SEOTools\SEOTools::getTitle() ?? flexiblePagesSetting(\Statikbe\FilamentFlexibleContentBlockPages\Models\Settings::SETTING_SITE_TITLE, app()->getLocale(), config('app.name') }}</title>
8+
<title>{{ $title }}</title>
99

1010
{!! \Artesaos\SEOTools\SEOTools::generate() !!}
1111

resources/views/pages/index.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/* @var Page $page */
66
@endphp
77

8-
<x-flexible-pages-layouts.base title="{{ $page->title }}" wide="true">
8+
<x-flexible-pages-base-layout title="{{ $page->title }}" wide="true">
99
<header>
1010
<x-flexible-pages-language-switch/>
1111
</header>
@@ -21,4 +21,4 @@
2121
<footer>
2222
<div>{{flexiblePagesSetting(Settings::SETTING_FOOTER_COPYRIGHT)}}</div>
2323
</footer>
24-
</x-flexible-pages-layouts.base>
24+
</x-flexible-pages-base-layout>

src/Components/LanguageSwitch.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99

1010
class LanguageSwitch extends Component
1111
{
12+
public function __construct(public string $title){}
13+
1214
public function render()
1315
{
1416
return view('filament-flexible-content-block-pages::components.language-switch');
1517
}
1618

1719
public function shouldRender(): bool
1820
{
19-
return count(LaravelLocalization::getSupportedLocales()) > 1;
21+
return !empty(LaravelLocalization::getSupportedLocales());
2022
}
2123
}

src/Http/Controllers/PageController.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@ public function index(Page $page)
4141
$this->setSEOLocalisationAndCanonicalUrl();
4242
$this->setSEOImage($page);
4343

44+
$title = $page->title ??
45+
SEOTools::getTitle() ??
46+
$this->getSettingsTitle();
47+
4448
return view(self::TEMPLATE_PATH, [
4549
'page' => $page,
50+
'title' => $title,
4651
]);
4752
}
4853

@@ -121,8 +126,8 @@ protected function getLocalisedUrls(): array
121126

122127
protected function setBasicSEO(Page $page)
123128
{
124-
SEOTools::setTitle(($page->seo_title ? $page->seo_title : $page->title).$this->getSEOTitlePostfix());
125-
SEOTools::setDescription(($page->seo_description ? $page->seo_description : strip_tags($page->intro)));
129+
SEOTools::setTitle(($page->seo_title ?? $page->title ?? $this->getSettingsTitle()).$this->getSEOTitlePostfix());
130+
SEOTools::setDescription(($page->seo_description ?? strip_tags($page->intro)));
126131
SEOTools::opengraph()->setUrl(url()->current());
127132
}
128133

@@ -181,4 +186,9 @@ function () use ($seoMedia, $conversion) {
181186
];
182187
});
183188
}
189+
190+
private function getSettingsTitle(): string
191+
{
192+
return flexiblePagesSetting(Settings::SETTING_SITE_TITLE, app()->getLocale(), config('app.name'));
193+
}
184194
}

0 commit comments

Comments
 (0)