From d1b27854eac98a98a165e061e794fca30cebcdcc Mon Sep 17 00:00:00 2001 From: Arik Chakma Date: Wed, 13 Mar 2024 13:17:12 +0600 Subject: [PATCH] chore: add open graph images --- src/pages/[roadmapId]/index.astro | 11 ++++++++-- src/pages/backend/developer-skills.astro | 21 ++++++++++++++----- src/pages/backend/languages.astro | 15 +++++++++++-- .../[bestPracticeId]/index.astro | 9 ++++++++ src/pages/guides/[guideId].astro | 13 +++++++++++- 5 files changed, 59 insertions(+), 10 deletions(-) diff --git a/src/pages/[roadmapId]/index.astro b/src/pages/[roadmapId]/index.astro index e30851491..dd4766915 100644 --- a/src/pages/[roadmapId]/index.astro +++ b/src/pages/[roadmapId]/index.astro @@ -55,14 +55,21 @@ if (roadmapData.schema) { if (roadmapFAQs.length) { jsonLdSchema.push(generateFAQSchema(roadmapFAQs)); } + +const ogImageUrl = + roadmapData?.seo?.ogImageUrl || + `${import.meta.env.PUBLIC_API_URL}/v1-open-graph?${new URLSearchParams({ + type: 'roadmap', + title: roadmapData.title, + description: roadmapData.description, + })}`; --- diff --git a/src/pages/backend/languages.astro b/src/pages/backend/languages.astro index 95a4a5a20..fe33e326f 100644 --- a/src/pages/backend/languages.astro +++ b/src/pages/backend/languages.astro @@ -7,7 +7,17 @@ import { getGuideById } from '../../lib/guide'; const guideId = 'backend-languages'; const guide = await getGuideById('backend-languages'); -const { frontmatter: guideData } = guide; +const { frontmatter: guideData, author } = guide!; + +const ogImageUrl = `${import.meta.env.PUBLIC_API_URL}/v1-open-graph?${new URLSearchParams( + { + type: 'guide', + title: guideData.title, + description: guideData.description, + authorName: author.frontmatter?.name, + authorAvatar: author.frontmatter?.imageUrl || '', + }, +)}`; --- - +
diff --git a/src/pages/best-practices/[bestPracticeId]/index.astro b/src/pages/best-practices/[bestPracticeId]/index.astro index ede49870b..d54c9a384 100644 --- a/src/pages/best-practices/[bestPracticeId]/index.astro +++ b/src/pages/best-practices/[bestPracticeId]/index.astro @@ -52,12 +52,21 @@ if (bestPracticeData.schema) { }), ); } + +const ogImageUrl = `${import.meta.env.PUBLIC_API_URL}/v1-open-graph?${new URLSearchParams( + { + type: 'roadmap', + title: bestPracticeData.title, + description: bestPracticeData.description, + }, +)}`; ---