mirror of
https://github.com/valentineus/popov.link.git
synced 2025-07-04 00:20:26 +03:00
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.
This commit is contained in:
@ -25,6 +25,7 @@ const formattedDate = dayjs(post.data.pubDate.toString()).format("MMMM DD, YYYY"
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
|
<article>
|
||||||
<a href={`/blog/${post.slug}`} lang={post.data.lang}>{post.data.title}</a>
|
<a href={`/blog/${post.slug}`} lang={post.data.lang}>{post.data.title}</a>
|
||||||
<div>
|
<div>
|
||||||
<small>
|
<small>
|
||||||
@ -33,4 +34,5 @@ const formattedDate = dayjs(post.data.pubDate.toString()).format("MMMM DD, YYYY"
|
|||||||
<span>{remarkPluginFrontmatter.minutesRead}</span>
|
<span>{remarkPluginFrontmatter.minutesRead}</span>
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
|
</article>
|
||||||
</li>
|
</li>
|
||||||
|
@ -30,6 +30,7 @@ const lang = "en";
|
|||||||
const schema = blogSchema({
|
const schema = blogSchema({
|
||||||
siteUrl: new URL("/", Astro.site).toString(),
|
siteUrl: new URL("/", Astro.site).toString(),
|
||||||
title,
|
title,
|
||||||
|
posts,
|
||||||
});
|
});
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -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 = {
|
export type BlogSchemaParams = {
|
||||||
readonly siteUrl: string;
|
readonly siteUrl: string;
|
||||||
readonly title: 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",
|
"@context": "https://schema.org",
|
||||||
"@type": "Blog",
|
"@type": "CollectionPage",
|
||||||
"url": new URL("/blog/", siteUrl).toString(),
|
"url": new URL("/blog/", siteUrl).toString(),
|
||||||
"name": title,
|
"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,
|
||||||
|
})),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user