{{-- 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]; } } $publisher = [ '@type' => 'NewsMediaOrganization', '@id' => rtrim(url('/'), '/') . '/#organization', 'name' => 'GOOI&meer', 'url' => url('/'), 'logo' => [ '@type' => 'ImageObject', 'url' => url('/android-chrome-512x512.png'), 'width' => 512, 'height' => 512, ], ]; $article = array_filter([ '@type' => 'NewsArticle', '@id' => $canonical . '#article', 'mainEntityOfPage' => ['@type' => 'WebPage', '@id' => $canonical], '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