$themes */ $themes = $trans['themes']; /** @var string $rawTitle */ $rawTitle = preg_replace('/\s+/', ' ', str_replace('
', ' ', $trans['header']['title'])); $title = trim(strip_tags($rawTitle)); /** @var array}> $questions */ $questions = $trans['questions']; $mainEntity = collect($questions) ->map(function (array $item): Question { /** @var array $blocks */ $blocks = $item['blocks']; $answerText = collect($blocks) ->where('type', 'text') ->map(fn (array $block) => trim(strip_tags((string) ($block['content'] ?? '')))) ->implode(' '); return Schema::question() ->name(strip_tags($item['question'])) ->acceptedAnswer( Schema::answer()->text($answerText) ); }) ->all(); $faqPage = Schema::faqPage(); $faqPage->setProperty('@id', request()->url() . '#faqpage'); $faqPage->mainEntity($mainEntity); $webPage = $schemaOrg->setWebPage() ->headline($trans['meta']['seo_title']) ->description($trans['meta']['seo_description']) ->name($title) ->isAccessibleForFree(true) ->keywords(array_values($themes)) ->dateCreated(new \DateTimeImmutable()) ->dateModified(new \DateTimeImmutable()) ->mainEntity( Schema::faqPage()->setProperty('@id', request()->url() . '#faqpage') ); return Inertia::render('front/Pages/QuestionsResponses', [ 'themes' => collect($themes) ->map(fn (string $label, string $value) => ['label' => $label, 'value' => $value]) ->values() ->all(), 'questions' => $questions, 'schemas' => [$webPage, $faqPage], ]); } }