|
10 | 10 | use Illuminate\Support\Facades\Auth;
|
11 | 11 | use Illuminate\Support\Facades\Cache;
|
12 | 12 | use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
|
| 13 | +use Spatie\Image\Image; |
13 | 14 | use Spatie\MediaLibrary\Conversions\ConversionCollection;
|
14 | 15 | use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
15 | 16 | use Statikbe\FilamentFlexibleContentBlockPages\Facades\FilamentFlexibleContentBlockPages;
|
@@ -41,13 +42,8 @@ public function index(Page $page)
|
41 | 42 | $this->setSEOLocalisationAndCanonicalUrl();
|
42 | 43 | $this->setSEOImage($page);
|
43 | 44 |
|
44 |
| - $title = $page->title ?? |
45 |
| - SEOTools::getTitle() ?? |
46 |
| - $this->getSettingsTitle(); |
47 |
| - |
48 | 45 | return view(self::TEMPLATE_PATH, [
|
49 | 46 | 'page' => $page,
|
50 |
| - 'title' => $title, |
51 | 47 | ]);
|
52 | 48 | }
|
53 | 49 |
|
@@ -81,8 +77,12 @@ public function grandchildIndex(Page $grandparent, Page $parent, Page $page)
|
81 | 77 | return $this->index($page);
|
82 | 78 | }
|
83 | 79 |
|
84 |
| - protected function getSEOTitlePostfix() |
| 80 | + protected function getSEOTitlePostfix(Page $page): string |
85 | 81 | {
|
| 82 | + if($page->isHomePage()) { |
| 83 | + return ''; |
| 84 | + } |
| 85 | + |
86 | 86 | return sprintf(' | %s', flexiblePagesSetting(Settings::SETTING_SITE_TITLE));
|
87 | 87 | }
|
88 | 88 |
|
@@ -126,7 +126,8 @@ protected function getLocalisedUrls(): array
|
126 | 126 |
|
127 | 127 | protected function setBasicSEO(Page $page)
|
128 | 128 | {
|
129 |
| - SEOTools::setTitle(($page->seo_title ?? $page->title ?? $this->getSettingsTitle()).$this->getSEOTitlePostfix()); |
| 129 | + $title = $page->seo_title ?? $page->title ?? $this->getSettingsTitle(); |
| 130 | + SEOTools::setTitle($title . $this->getSEOTitlePostfix($page), false); |
130 | 131 | SEOTools::setDescription(($page->seo_description ?? strip_tags($page->intro)));
|
131 | 132 | SEOTools::opengraph()->setUrl(url()->current());
|
132 | 133 | }
|
@@ -177,12 +178,12 @@ protected function getSEOImageDimensions(Media $seoMedia, string $conversion)
|
177 | 178 | return Cache::remember($cacheKey,
|
178 | 179 | self::CACHE_SEO_IMAGE_TTL,
|
179 | 180 | function () use ($seoMedia, $conversion) {
|
180 |
| - $conversionCollection = ConversionCollection::createForMedia($seoMedia); |
181 |
| - $conversion = $conversionCollection->getByName($conversion); |
| 181 | + $filePath = $seoMedia->getPath($conversion); |
| 182 | + $image = Image::load($filePath); |
182 | 183 |
|
183 | 184 | return [
|
184 |
| - 'width' => $conversion->getWidth(), |
185 |
| - 'height' => $conversion->getHeight(), |
| 185 | + 'width' => $image->getWidth(), |
| 186 | + 'height' => $image->getHeight(), |
186 | 187 | ];
|
187 | 188 | });
|
188 | 189 | }
|
|
0 commit comments