diff options
author | Valentin Popov <valentin@popov.link> | 2025-06-14 14:01:42 +0300 |
---|---|---|
committer | Valentin Popov <valentin@popov.link> | 2025-06-14 14:01:42 +0300 |
commit | 9777d996d172755472dd8127ff9b7a3c579cf454 (patch) | |
tree | f8f2cae618f6508750b79973e9e911a582166953 /src | |
parent | 1c15151ef59d3a0e7f4bb03a65bcd1970f3e1c07 (diff) | |
download | popov.link-9777d996d172755472dd8127ff9b7a3c579cf454.tar.xz popov.link-9777d996d172755472dd8127ff9b7a3c579cf454.zip |
refactor: enhance PostElement structure and update blog schema
- Wrapped the post link in an <article> tag for improved semantic structure.
- Updated blogSchema to include posts for better structured data representation.
- Adjusted the blog index to utilize the new posts parameter for enhanced SEO.
Diffstat (limited to 'src')
-rw-r--r-- | src/components/PostElement.astro | 18 | ||||
-rw-r--r-- | src/pages/blog/index.astro | 1 | ||||
-rw-r--r-- | src/utils/schemas/blogSchema.ts | 17 |
3 files changed, 25 insertions, 11 deletions
diff --git a/src/components/PostElement.astro b/src/components/PostElement.astro index 2263e92..85320ee 100644 --- a/src/components/PostElement.astro +++ b/src/components/PostElement.astro @@ -25,12 +25,14 @@ const formattedDate = dayjs(post.data.pubDate.toString()).format("MMMM DD, YYYY" </style> <li> - <a href={`/blog/${post.slug}`} lang={post.data.lang}>{post.data.title}</a> - <div> - <small> - <time datetime={post.data.pubDate.toISOString()} lang="en">{formattedDate}</time> - <span>•</span> - <span>{remarkPluginFrontmatter.minutesRead}</span> - </small> - </div> + <article> + <a href={`/blog/${post.slug}`} lang={post.data.lang}>{post.data.title}</a> + <div> + <small> + <time datetime={post.data.pubDate.toISOString()} lang="en">{formattedDate}</time> + <span>•</span> + <span>{remarkPluginFrontmatter.minutesRead}</span> + </small> + </div> + </article> </li> diff --git a/src/pages/blog/index.astro b/src/pages/blog/index.astro index 611d0fc..fd8b376 100644 --- a/src/pages/blog/index.astro +++ b/src/pages/blog/index.astro @@ -30,6 +30,7 @@ const lang = "en"; const schema = blogSchema({ siteUrl: new URL("/", Astro.site).toString(), title, + posts, }); --- diff --git a/src/utils/schemas/blogSchema.ts b/src/utils/schemas/blogSchema.ts index 7ff84d8..54e2fca 100644 --- a/src/utils/schemas/blogSchema.ts +++ b/src/utils/schemas/blogSchema.ts @@ -1,13 +1,24 @@ -import type { WithContext, Blog } from "schema-dts"; +import type { WithContext, CollectionPage } from "schema-dts"; +import type { CollectionEntry } from "astro:content"; export type BlogSchemaParams = { readonly siteUrl: string; readonly title: string; + readonly posts: CollectionEntry<"blog">[]; }; -export default ({ siteUrl, title }: BlogSchemaParams): WithContext<Blog> => ({ +export default ({ siteUrl, title, posts }: BlogSchemaParams): WithContext<CollectionPage> => ({ "@context": "https://schema.org", - "@type": "Blog", + "@type": "CollectionPage", "url": new URL("/blog/", siteUrl).toString(), "name": title, + "mainEntity": { + "@type": "ItemList", + "itemListElement": posts.map((post, index) => ({ + "@type": "ListItem", + "position": index + 1, + "url": new URL(`/blog/${post.slug}`, siteUrl).toString(), + "name": post.data.title, + })), + }, }); |