aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-04-22 19:11:58 +0300
committerValentin Popov <valentin@popov.link>2026-04-22 19:11:58 +0300
commit5e818d804d5d38beff0f3754a006333752fd5082 (patch)
tree7f2d1097390bbdb3c5fa1593f6d15d6dfb3b0dd8 /src/components
parent41bb3099660b6210a419c4190a1bc08d7ba58c00 (diff)
downloadpopov.link-5e818d804d5d38beff0f3754a006333752fd5082.tar.xz
popov.link-5e818d804d5d38beff0f3754a006333752fd5082.zip
refactor: update schema handling and improve SEO metadata
- 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.
Diffstat (limited to 'src/components')
-rw-r--r--src/components/Head.astro9
-rw-r--r--src/components/JsonLd.astro12
2 files changed, 14 insertions, 7 deletions
diff --git a/src/components/Head.astro b/src/components/Head.astro
index 3fded95..258162d 100644
--- a/src/components/Head.astro
+++ b/src/components/Head.astro
@@ -1,15 +1,16 @@
---
-import type { WithContext, Thing } from "schema-dts";
+import type { Thing } from "schema-dts";
import JsonLd from "./JsonLd.astro";
type Props = {
readonly description: string;
readonly preview: string;
- readonly schema: WithContext<Thing>;
+ readonly robots?: string;
+ readonly schema: Thing[];
readonly title: string;
};
-const { description, preview, schema, title } = Astro.props;
+const { description, preview, robots = "index, follow", schema, title } = Astro.props;
const canonicalUrl = new URL(Astro.url.pathname, Astro.site);
const previewUrl = new URL(preview, Astro.site);
@@ -21,7 +22,7 @@ const previewUrl = new URL(preview, Astro.site);
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content={description} />
- <meta name="robots" content="index, follow" />
+ <meta name="robots" content={robots} />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="/feed.xml" rel="alternate" title="RSS" type="application/atom+xml" />
diff --git a/src/components/JsonLd.astro b/src/components/JsonLd.astro
index b58efd7..d12cb78 100644
--- a/src/components/JsonLd.astro
+++ b/src/components/JsonLd.astro
@@ -1,12 +1,18 @@
---
-import type { WithContext, Thing } from "schema-dts";
+import type { Thing } from "schema-dts";
type Props = {
- readonly schema: WithContext<Thing>;
+ readonly schema: Thing[];
};
const { schema } = Astro.props;
-const json = JSON.stringify(schema);
+
+const payload = {
+ "@context": "https://schema.org",
+ "@graph": schema,
+};
+
+const json = JSON.stringify(payload);
---
<!-- JSON-LD -->