diff options
| author | Valentin Popov <valentin@popov.link> | 2026-04-22 19:11:58 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-04-22 19:11:58 +0300 |
| commit | 5e818d804d5d38beff0f3754a006333752fd5082 (patch) | |
| tree | 7f2d1097390bbdb3c5fa1593f6d15d6dfb3b0dd8 /src/pages | |
| parent | 41bb3099660b6210a419c4190a1bc08d7ba58c00 (diff) | |
| download | popov.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/pages')
| -rw-r--r-- | src/pages/404.astro | 20 | ||||
| -rw-r--r-- | src/pages/blog/[...slug].astro | 44 | ||||
| -rw-r--r-- | src/pages/blog/index.astro | 20 | ||||
| -rw-r--r-- | src/pages/index.astro | 12 |
4 files changed, 63 insertions, 33 deletions
diff --git a/src/pages/404.astro b/src/pages/404.astro index 3ec9feb..e76215e 100644 --- a/src/pages/404.astro +++ b/src/pages/404.astro @@ -8,16 +8,20 @@ const description = "The page you're looking for doesn't exist!"; const preview = config.og.defaultPreview; const lang = "en"; -const schema = pageSchema({ - siteUrl: new URL("/", Astro.site).toString(), - page: "/404", - title, - description, - lang, -}); +const siteUrl = new URL("/", Astro.site).toString(); + +const schema = [ + pageSchema({ + siteUrl, + page: "/404", + title, + description, + lang, + }), +]; --- -<Layout title={title} description={description} preview={preview} lang={lang} schema={schema}> +<Layout title={title} description={description} preview={preview} lang={lang} robots="noindex, follow" schema={schema}> <div style={{ "text-align": "center" }}> <h1>404</h1> <p><strong>Page not found</strong></p> diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index 3bd2c61..5ba6b3b 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -1,9 +1,13 @@ --- import { type CollectionEntry, getCollection, render } from "astro:content"; -import Comments from "../../components/Comments.astro"; -import Layout from "../../layouts/BaseLayout.astro"; import blogPostSchema from "../../utils/schemas/blogPostSchema"; +import breadcrumbSchema from "../../utils/schemas/breadcrumbSchema"; +import Comments from "../../components/Comments.astro"; import dayjs from "dayjs"; +import Layout from "../../layouts/BaseLayout.astro"; +import personSchema from "../../utils/schemas/personSchema"; +import websiteSchema from "../../utils/schemas/websiteSchema"; +import { config } from "../../config"; type Props = CollectionEntry<"blog">; @@ -33,17 +37,31 @@ const dateModified = post.data.dateModified?.toISOString(); const datePublished = post.data.datePublished.toISOString(); const formattedDate = dayjs(post.data.datePublished.toString()).format("MMMM DD, YYYY"); -const schema = blogPostSchema({ - siteUrl: new URL("/", Astro.site).toString(), - dateModified, - datePublished, - description, - isBasedOn, - lang, - preview, - slug, - title, -}); +const siteUrl = new URL("/", Astro.site).toString(); + +const schema = [ + websiteSchema({ siteUrl, name: config.og.website, description, lang }), + personSchema({ siteUrl }), + blogPostSchema({ + siteUrl, + dateModified, + datePublished, + description, + isBasedOn, + lang, + preview, + slug, + title, + }), + breadcrumbSchema({ + siteUrl, + items: [ + { name: "Home", url: "/" }, + { name: "Blog", url: "/blog/" }, + { name: title, url: `/blog/${slug}` }, + ], + }), +]; --- <style lang="scss"> diff --git a/src/pages/blog/index.astro b/src/pages/blog/index.astro index 3a27111..aa1b46c 100644 --- a/src/pages/blog/index.astro +++ b/src/pages/blog/index.astro @@ -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}> diff --git a/src/pages/index.astro b/src/pages/index.astro index b235b9b..b9c6400 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -3,21 +3,19 @@ import { config } from "../config"; import LatestPostsSection from "../components/Sections/LatestPosts.astro"; import Layout from "../layouts/BaseLayout.astro"; import pageSchema from "../utils/schemas/pageSchema"; +import personSchema from "../utils/schemas/personSchema"; import SocialLinksSection from "../components/Sections/SocialLinks.astro"; import WelcomeSection from "../components/Sections/Welcome.astro"; +import websiteSchema from "../utils/schemas/websiteSchema"; const title = "Valentin Popov – Software Developer & Team Lead | Tech Insights"; const description = "Blog by Valentin Popov — software developer and team lead writing about code, side projects, digital tools, and fun experiments."; const preview = config.og.defaultPreview; const lang = "en"; -const schema = pageSchema({ - siteUrl: new URL("/", Astro.site).toString(), - page: "/", - title, - description, - lang, -}); +const siteUrl = new URL("/", Astro.site).toString(); + +const schema = [websiteSchema({ siteUrl, name: config.og.website, description, lang }), personSchema({ siteUrl }), pageSchema({ siteUrl, page: "/", title, description, lang, type: "ProfilePage" })]; --- <Layout title={title} description={description} preview={preview} lang={lang} schema={schema}> |
