settings->get(self::MODE) === 'builder' && $this->published() !== null; } public function setMode(string $mode): void { $this->settings->set(self::MODE, $mode === 'builder' ? 'builder' : 'widgets'); } public function mode(): string { return $this->settings->get(self::MODE) === 'builder' ? 'builder' : 'widgets'; } protected function prefix(): string { return 'homepage'; } /** * @return array{blocks: list>} */ protected function initial(): array { return $this->fromWidgets(); } /** * Anzeige für eine Person (veröffentlicht oder – in der Vorschau – der Entwurf). * * @return array{blocks: list>} */ public function render(User $user, bool $draft = false): array { return $this->content->render($draft ? $this->working() : ($this->published() ?? ['blocks' => []]), $user, ['homepage' => true]); } /** * Die heutige Kachel-Startseite als Blöcke: oben die Banner, darunter zwei Spalten * (Hauptbereich und Seitenleiste). * * @return array{blocks: list>} */ public function fromWidgets(): array { $areas = app(Widgets::class)->arrangement(); $block = fn (string $key) => ['id' => Str::random(12), 'type' => self::WIDGET_BLOCK, 'data' => ['widget' => $key]]; $main = array_map($block, [...array_slice($areas['hero'] ?? [], 0, 1), ...($areas['feed'] ?? []), ...($areas['main'] ?? [])]); $aside = array_map($block, $areas['aside'] ?? []); return $this->content->sanitize(['blocks' => [ ...array_map($block, $areas['top'] ?? []), ['id' => Str::random(12), 'type' => 'columns', 'data' => ['layout' => '2-1', 'stack' => 'md', 'gap' => 'normal', 'align' => 'start'], 'items' => [ ['id' => Str::random(12), 'blocks' => $main], ['id' => Str::random(12), 'blocks' => $aside], ]], ]]); } }