{{-- Structured data (schema.org JSON-LD) for a news article: NewsArticle with GOOI&meer as publisher, and the breadcrumb. Used by search engines (Google News / Top Stories) and AI assistants to understand the article. --}} @php $canonical = url()->current(); $absolute = function ($image) use ($imgBase) { return $image['own'] ? $imgBase . $image['url'] : $image['url']; }; $images = array_map($absolute, $news->imageList()); $tags = $news->tagTitles(); // "Saskia Plokker, Bart Koomen" / "A en B" -> separate authors; // an affiliation in brackets ("Elsa Poorthuis (Gooi & Meer)") is dropped $authors = []; $authorText = preg_replace('/\s*\([^)]*\)/u', '', trim(strip_tags((string) $news->author))); foreach (preg_split('/\s*(?:,|\s&\s|\s+en\s+)\s*/u', $authorText) as $name) { if ($name !== '') { $authors[] = ['@type' => 'Person', 'name' => $name]; } } // Same organization as in partial/site_jsonld (config/seo.php); name and // logo are repeated here because Google expects them on the publisher $org = config('seo.organization'); $home = rtrim(url('/'), '/') . '/'; $publisher = [ '@type' => 'NewsMediaOrganization', '@id' => $home . '#organization', 'name' => $org['name'], 'url' => $home, 'logo' => [ '@type' => 'ImageObject', 'url' => url($org['logo']), 'width' => $org['logo_width'], 'height' => $org['logo_height'], ], ]; $article = array_filter([ '@type' => 'NewsArticle', '@id' => $canonical . '#article', 'mainEntityOfPage' => ['@type' => 'WebPage', '@id' => $canonical], 'isPartOf' => ['@id' => $home . '#website'], 'url' => $canonical, 'headline' => mb_substr($news->plainTitle(), 0, 110), 'description' => $news->summary(200), 'image' => $images ?: null, 'datePublished' => $news->published ? $news->published->format(DATE_ATOM) : null, 'dateModified' => ($news->edited ?: $news->published) ? ($news->edited ?: $news->published)->format(DATE_ATOM) : null, 'author' => $authors ?: $publisher, 'publisher' => $publisher, 'articleSection' => $tags[0] ?? null, 'keywords' => $tags ? implode(', ', $tags) : null, 'inLanguage' => 'nl-NL', 'isAccessibleForFree' => true, ]); $breadcrumb = [ '@type' => 'BreadcrumbList', 'itemListElement' => [ ['@type' => 'ListItem', 'position' => 1, 'name' => 'Home', 'item' => url('/')], ['@type' => 'ListItem', 'position' => 2, 'name' => 'Nieuws', 'item' => route('nieuws')], ['@type' => 'ListItem', 'position' => 3, 'name' => $news->plainTitle(), 'item' => $canonical], ], ]; $jsonld = ['@context' => 'https://schema.org', '@graph' => [$article, $breadcrumb]]; @endphp