Merge branch 'feature/seo-listing-pages' into dev
This commit is contained in:
commit
9d3b21359e
4 files changed
+130
-10
No files matched your search
@@ -0,0 +1,51 @@
|
||||
{{--
|
||||
Structured data (schema.org JSON-LD) for a news overview page (tag, region,
|
||||
theme): a CollectionPage with the articles on this page as an ItemList, and
|
||||
the breadcrumb. Parameters: $title, $news, $canonical, $pageNumber.
|
||||
--}}
|
||||
@php
|
||||
$home = rtrim(url('/'), '/') . '/';
|
||||
$firstPage = strtok($canonical, '?');
|
||||
// Position across pages: the articles on page N follow those of the earlier pages
|
||||
$offset = ($pageNumber - 1) * count($news);
|
||||
|
||||
$items = [];
|
||||
foreach (array_values($news) as $i => $item) {
|
||||
$items[] = [
|
||||
'@type' => 'ListItem',
|
||||
'position' => $offset + $i + 1,
|
||||
'url' => url($item->url),
|
||||
'name' => $item->plainTitle(),
|
||||
];
|
||||
}
|
||||
|
||||
$collection = [
|
||||
'@type' => 'CollectionPage',
|
||||
'@id' => $canonical . '#collection',
|
||||
'url' => $canonical,
|
||||
'name' => $title . ' - Nieuws' . ($pageNumber > 1 ? ' (pagina ' . $pageNumber . ')' : ''),
|
||||
'description' => 'Het laatste nieuws over ' . $title . ' van GOOI&meer, de streekomroep voor Gooi & Vechtstreek.',
|
||||
'about' => ['@type' => 'Thing', 'name' => $title],
|
||||
'inLanguage' => 'nl-NL',
|
||||
'isPartOf' => ['@id' => $home . '#website'],
|
||||
'publisher' => ['@id' => $home . '#organization'],
|
||||
'mainEntity' => [
|
||||
'@type' => 'ItemList',
|
||||
'itemListOrder' => 'https://schema.org/ItemListOrderDescending',
|
||||
'numberOfItems' => count($items),
|
||||
'itemListElement' => $items,
|
||||
],
|
||||
];
|
||||
|
||||
$breadcrumb = [
|
||||
'@type' => 'BreadcrumbList',
|
||||
'itemListElement' => [
|
||||
['@type' => 'ListItem', 'position' => 1, 'name' => 'Home', 'item' => $home],
|
||||
['@type' => 'ListItem', 'position' => 2, 'name' => 'Nieuws', 'item' => route('nieuws')],
|
||||
['@type' => 'ListItem', 'position' => 3, 'name' => $title, 'item' => $firstPage],
|
||||
],
|
||||
];
|
||||
|
||||
$jsonld = ['@context' => 'https://schema.org', '@graph' => [$collection, $breadcrumb]];
|
||||
@endphp
|
||||
<script type="application/ld+json">{!! json_encode($jsonld, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_HEX_TAG | JSON_PRETTY_PRINT) !!}</script>
|
||||
Reference in new issue
Block a user