refactor: update schema handling and improve SEO metadata
RenovateBot / renovate (push) Successful in 26s
Test / npm test (push) Successful in 46s

- Changed schema type from WithContext<Thing> to Thing[] in Head, BaseLayout, and JsonLd components for better flexibility.
- Added optional robots meta tag to Head component.
- Updated JSON-LD generation in JsonLd component to include a structured payload.
- Enhanced page and blog schemas to support breadcrumb and person schemas for improved SEO.
- Introduced new utility schemas for website and person to streamline schema generation.
- Refactored existing schemas to align with the new structure and ensure consistency across components.
This commit is contained in:
2026-04-22 16:11:58 +00:00
parent 41bb309966
commit 5e818d804d
14 changed files with 227 additions and 101 deletions
+15 -5
View File
@@ -3,9 +3,11 @@ import type { CollectionEntry } from "astro:content";
import { config } from "../../config";
import { getCollection } from "astro:content";
import blogSchema from "../../utils/schemas/blogSchema";
import breadcrumbSchema from "../../utils/schemas/breadcrumbSchema";
import Layout from "../../layouts/BaseLayout.astro";
import PostElement from "../../components/PostElement.astro";
import RSSIcon from "../../components/Icons/RSS.astro";
import websiteSchema from "../../utils/schemas/websiteSchema";
const posts = await getCollection("blog", ({ data }) => {
return data.draft !== true;
@@ -29,11 +31,19 @@ const description = "Explore Valentin Popov's blog on software development, tech
const preview = config.og.defaultPreview;
const lang = "en";
const schema = blogSchema({
siteUrl: new URL("/", Astro.site).toString(),
title,
posts,
});
const siteUrl = new URL("/", Astro.site).toString();
const schema = [
websiteSchema({ siteUrl, name: config.og.website, description, lang }),
blogSchema({ siteUrl, title, description, lang, posts }),
breadcrumbSchema({
siteUrl,
items: [
{ name: "Home", url: "/" },
{ name: "Blog", url: "/blog/" },
],
}),
];
---
<Layout title={title} description={description} preview={preview} lang={lang} schema={schema}>