From 67f245a48faf6e89989aca2ea571b657fd4c8888 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 11 Jun 2025 23:20:36 +0000 Subject: feat: integrate schema.org support and enhance component structure - Added schema.org support by introducing `schema-dts` for structured data in components. - Updated `Head`, `BaseLayout`, and various page components to accept and utilize schema props for better SEO. - Created new utility schemas for blog posts and website to standardize structured data implementation. - Enhanced the `SocialLinks` section by utilizing dedicated icon components for improved maintainability. - Refactored the `Header` component to improve accessibility and structure. - Introduced new icons for social links and integrated them into the layout. --- src/components/Analytics.astro | 1 - src/components/Head.astro | 8 +++++- src/components/Header.astro | 7 +++--- src/components/Icons/Email.astro | 20 +++++++++++++++ src/components/Icons/GitHub.astro | 22 ++++++++++++++++ src/components/Icons/LinkedIn.astro | 21 ++++++++++++++++ src/components/Icons/RSS.astro | 17 +++++++++++++ src/components/JsonLd.astro | 12 +++++++++ src/components/Sections/LatestPosts.astro | 10 ++++++-- src/components/Sections/SocialLinks.astro | 42 +++++++------------------------ src/components/Sections/Welcome.astro | 2 +- src/layouts/BaseLayout.astro | 6 +++-- src/pages/404.astro | 10 ++++++-- src/pages/blog/[...slug].astro | 24 +++++++++++++----- src/pages/blog/index.astro | 24 ++++++++++++------ src/pages/index.astro | 10 ++++++-- src/utils/schemas/blogPostSchema.ts | 21 ++++++++++++++++ src/utils/schemas/blogSchema.ts | 13 ++++++++++ src/utils/schemas/websiteSchema.ts | 13 ++++++++++ 19 files changed, 223 insertions(+), 60 deletions(-) create mode 100644 src/components/Icons/Email.astro create mode 100644 src/components/Icons/GitHub.astro create mode 100644 src/components/Icons/LinkedIn.astro create mode 100644 src/components/Icons/RSS.astro create mode 100644 src/components/JsonLd.astro create mode 100644 src/utils/schemas/blogPostSchema.ts create mode 100644 src/utils/schemas/blogSchema.ts create mode 100644 src/utils/schemas/websiteSchema.ts (limited to 'src') diff --git a/src/components/Analytics.astro b/src/components/Analytics.astro index 3be88c7..0c22f52 100644 --- a/src/components/Analytics.astro +++ b/src/components/Analytics.astro @@ -1,2 +1 @@ - diff --git a/src/components/Head.astro b/src/components/Head.astro index de74ff2..a421915 100644 --- a/src/components/Head.astro +++ b/src/components/Head.astro @@ -1,11 +1,15 @@ --- +import type { WithContext, Thing } from "schema-dts"; +import JsonLd from "./JsonLd.astro"; + type Props = { readonly description: string; readonly title: string; + readonly schema: WithContext; }; const canonicalURL = new URL(Astro.url.pathname, Astro.site); -const { description, title } = Astro.props; +const { description, title, schema } = Astro.props; --- @@ -27,4 +31,6 @@ const { description, title } = Astro.props; + + diff --git a/src/components/Header.astro b/src/components/Header.astro index bd04320..f9a0c57 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -1,7 +1,6 @@
- Home - Blog +
diff --git a/src/components/Icons/Email.astro b/src/components/Icons/Email.astro new file mode 100644 index 0000000..053b84e --- /dev/null +++ b/src/components/Icons/Email.astro @@ -0,0 +1,20 @@ + + + + + + + + diff --git a/src/components/Icons/GitHub.astro b/src/components/Icons/GitHub.astro new file mode 100644 index 0000000..39a6c1f --- /dev/null +++ b/src/components/Icons/GitHub.astro @@ -0,0 +1,22 @@ + + + + + + + + diff --git a/src/components/Icons/LinkedIn.astro b/src/components/Icons/LinkedIn.astro new file mode 100644 index 0000000..5e87e86 --- /dev/null +++ b/src/components/Icons/LinkedIn.astro @@ -0,0 +1,21 @@ + + + + + + + + + diff --git a/src/components/Icons/RSS.astro b/src/components/Icons/RSS.astro new file mode 100644 index 0000000..67f4c42 --- /dev/null +++ b/src/components/Icons/RSS.astro @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/src/components/JsonLd.astro b/src/components/JsonLd.astro new file mode 100644 index 0000000..a589f7b --- /dev/null +++ b/src/components/JsonLd.astro @@ -0,0 +1,12 @@ +--- +import type { WithContext, Thing } from "schema-dts"; + +type Props = { + readonly schema: WithContext; +}; + +const { schema } = Astro.props; +const json = JSON.stringify(schema); +--- + +