Ein Foto gehoert zu keinem (ganzjaehrig) oder mehreren Erscheinungsbildern und erscheint nur dort, vor den ganzjaehrigen Fotos. Bausteine waehlen "automatisch" oder eine eigene Auswahl; Titelbereich und Abschluss zeigen das erste passende Foto ihrer Liste. Titelbild und "Bilder je Baustein" des Erscheinungsbilds werden in die Bausteine uebernommen und entfallen dort. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
99 lines
3.3 KiB
PHP
99 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Page;
|
|
use App\Support\Content;
|
|
use App\Themes\SectionRegistry;
|
|
use App\Themes\Theme;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\Http\Response;
|
|
|
|
/**
|
|
* Renders the website pages of the current site with the active theme.
|
|
*/
|
|
class PageController extends Controller
|
|
{
|
|
public function __construct(private SectionRegistry $sections) {}
|
|
|
|
/**
|
|
* Resolved per call: the controller is built before the middleware has determined site and appearance.
|
|
*/
|
|
private function theme(): Theme
|
|
{
|
|
return app(Theme::class);
|
|
}
|
|
|
|
public function home(): View
|
|
{
|
|
return $this->show(Page::HOME);
|
|
}
|
|
|
|
public function show(string $slug): View
|
|
{
|
|
abort_unless($this->theme()->site->exists, 404);
|
|
|
|
$page = $this->theme()->site->pages()
|
|
->where('slug', $slug)
|
|
->where('is_published', true)
|
|
->firstOrFail();
|
|
|
|
return view('theme::page', [
|
|
'page' => $page,
|
|
'sections' => $this->sections->render($this->theme(), $page->sections),
|
|
'title' => $page->isHome() ? null : ($page->seo_title ?: $page->title),
|
|
'description' => $page->seo_description ?: ($page->isHome() ? Content::get('seo.home.description') : null),
|
|
'ogImage' => $this->theme()->sharePhoto($page->sections ?? [])?->url('lg') ?: null,
|
|
'structuredData' => $page->isHome() ? $this->structuredData($page) : null,
|
|
]);
|
|
}
|
|
|
|
public function sitemap(): Response
|
|
{
|
|
$pages = $this->theme()->site->exists
|
|
? $this->theme()->site->pages()->where('is_published', true)->get()
|
|
: collect();
|
|
|
|
return response()->view('sitemap', ['pages' => $pages], 200, ['Content-Type' => 'application/xml']);
|
|
}
|
|
|
|
public function robots(): Response
|
|
{
|
|
return response(implode("\n", [
|
|
'User-agent: *',
|
|
'Disallow: /admin',
|
|
'Disallow: /livewire',
|
|
'Disallow: /automation',
|
|
'Disallow: /bewertung',
|
|
'Disallow: /angebote',
|
|
'Disallow: /angebot/',
|
|
'Sitemap: '.route('sitemap'),
|
|
'',
|
|
]), 200, ['Content-Type' => 'text/plain; charset=UTF-8']);
|
|
}
|
|
|
|
/**
|
|
* schema.org data of the property for search engines.
|
|
*
|
|
* @return array<string, mixed>|null
|
|
*/
|
|
private function structuredData(Page $page): ?array
|
|
{
|
|
$property = $this->theme()->property();
|
|
if ($property === null) {
|
|
return null;
|
|
}
|
|
|
|
return array_filter([
|
|
'@context' => 'https://schema.org',
|
|
'@type' => 'VacationRental',
|
|
'name' => $property->name,
|
|
'url' => route('home'),
|
|
'image' => $this->theme()->sharePhoto($page->sections ?? [])?->url('lg') ?: null,
|
|
'address' => ['@type' => 'PostalAddress', 'streetAddress' => str($property->address)->before(',')->trim()->toString(), 'addressLocality' => 'Kühlungsborn', 'postalCode' => '18225', 'addressCountry' => 'DE'],
|
|
'containsPlace' => ['@type' => 'Accommodation', 'floorSize' => ['@type' => 'QuantitativeValue', 'value' => $property->size_sqm, 'unitCode' => 'MTK'], 'occupancy' => ['@type' => 'QuantitativeValue', 'maxValue' => $property->max_guests]],
|
|
'telephone' => config('fewo.owner.phone'),
|
|
]);
|
|
}
|
|
}
|