22import type { GetStaticPaths } from " astro" ;
33import { fetchData , type Article , type Page as PageType } from " @xprtz/cms" ;
44import Layout from " ../../../layouts/layout.astro" ;
5- import { Container , Blogs } from " @xprtz/ui" ;
5+ import {
6+ Container ,
7+ Blogs ,
8+ SEOTools ,
9+ generateWebsiteStructuredData ,
10+ } from " @xprtz/ui" ;
611
712interface PageData {
813 data: Article [];
@@ -44,6 +49,8 @@ export const getStaticPaths: GetStaticPaths = async ({ paginate }) => {
4449};
4550
4651const site = import .meta .env .PUBLIC_SITE || " no-site-found" ;
52+ const siteUrl = Astro .site ?.toString () || " https://xprtz.net" ;
53+
4754const articlesPages = await fetchData <Array <PageType >>({
4855 endpoint: " pages" ,
4956 wrappedByKey: " data" ,
@@ -55,14 +62,66 @@ const articlesPages = await fetchData<Array<PageType>>({
5562});
5663
5764const { page } = Astro .props as { page: PageData };
58-
5965const articlesPage = articlesPages [0 ];
66+
67+ // Generate pagination URLs
68+ const prevPageUrl = page .url .prev ? ` ${siteUrl }${page .url .prev } ` : undefined ;
69+ const nextPageUrl = page .url .next ? ` ${siteUrl }${page .url .next } ` : undefined ;
70+
71+ // Generate structured data for the blog listing page
72+ const structuredData = generateWebsiteStructuredData ({
73+ name: ` ${articlesPage .title_website } - Pagina ${page .currentPage } ` ,
74+ url: ` ${siteUrl }${page .url .current } ` ,
75+ description: ` ${articlesPage .description } - Pagina ${page .currentPage } van ${page .lastPage } ` ,
76+ });
77+
78+ // Generate breadcrumbs
79+ const breadcrumbs = [
80+ { name: " Home" , url: siteUrl },
81+ { name: articlesPage .title_website , url: ` ${siteUrl }/artikelen/ ` },
82+ ... (Number (page .currentPage ) > 1
83+ ? [
84+ {
85+ name: ` Pagina ${page .currentPage } ` ,
86+ url: ` ${siteUrl }${page .url .current } ` ,
87+ },
88+ ]
89+ : []),
90+ ];
91+
92+ // Create page-specific title and description
93+ const pageTitle =
94+ Number (page .currentPage ) > 1
95+ ? ` ${articlesPage .title_website } - Pagina ${page .currentPage } `
96+ : articlesPage .title_website ;
97+
98+ const pageDescription =
99+ Number (page .currentPage ) > 1
100+ ? ` ${articlesPage .description } - Pagina ${page .currentPage } van ${page .lastPage } `
101+ : articlesPage .description ;
60102---
61103
62104<Layout
63- title ={ articlesPage .title_website }
64- description ={ articlesPage .description }
105+ title ={ pageTitle }
106+ description ={ pageDescription }
107+ type =" website"
108+ seoData ={ {
109+ structuredData ,
110+ keywords: [
111+ " articles" ,
112+ " blog posts" ,
113+ " .NET development" ,
114+ " software engineering" ,
115+ " programming tutorials" ,
116+ ],
117+ }}
65118>
119+ <SEOTools
120+ prevPage ={ prevPageUrl }
121+ nextPage ={ nextPageUrl }
122+ breadcrumbs ={ breadcrumbs }
123+ />
124+
66125 <Container >
67126 <svg
68127 class =" absolute inset-x-0 top-0 -z-10 h-[64rem] w-full stroke-gray-200 [mask-image:radial-gradient(32rem_32rem_at_center,white,transparent)]"
@@ -113,11 +172,11 @@ const articlesPage = articlesPages[0];
113172 <h1
114173 class =" mt-2 text-pretty text-4xl font-semibold tracking-tight text-primary-800 sm:text-5xl"
115174 >
116- { articlesPage . title_website }
175+ { pageTitle }
117176 </h1 >
118- <p class =" mt-6 text-xl/8" >{ articlesPage . description } </p >
177+ <p class =" mt-6 text-xl/8" >{ pageDescription } </p >
119178 <div class =" mt-10 max-w-7xl text-base/7" >
120- <Blogs page ={ page } />
179+ <Blogs page ={ page } />
121180 </div >
122181 </div >
123182 </div >
0 commit comments