chore: add open graph images

feat/open-graph
Arik Chakma 9 months ago
parent f838b5dac7
commit d1b27854ea
  1. 11
      src/pages/[roadmapId]/index.astro
  2. 21
      src/pages/backend/developer-skills.astro
  3. 15
      src/pages/backend/languages.astro
  4. 9
      src/pages/best-practices/[bestPracticeId]/index.astro
  5. 13
      src/pages/guides/[guideId].astro

@ -55,14 +55,21 @@ if (roadmapData.schema) {
if (roadmapFAQs.length) { if (roadmapFAQs.length) {
jsonLdSchema.push(generateFAQSchema(roadmapFAQs)); 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,
})}`;
--- ---
<BaseLayout <BaseLayout
permalink={`/${roadmapId}`} permalink={`/${roadmapId}`}
title={roadmapData?.seo?.title} title={roadmapData?.seo?.title}
briefTitle={roadmapData.briefTitle} briefTitle={roadmapData.briefTitle}
ogImageUrl={roadmapData?.seo?.ogImageUrl || ogImageUrl={ogImageUrl}
'https://roadmap.sh/images/og-img.png'}
description={roadmapData.seo.description} description={roadmapData.seo.description}
keywords={roadmapData.seo.keywords} keywords={roadmapData.seo.keywords}
noIndex={roadmapData.isUpcoming} noIndex={roadmapData.isUpcoming}

@ -7,14 +7,25 @@ import { getGuideById } from '../../lib/guide';
const guideId = 'backend-developer-skills'; const guideId = 'backend-developer-skills';
const guide = await getGuideById(guideId); const guide = await getGuideById(guideId);
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 || '',
},
)}`;
--- ---
<BaseLayout <BaseLayout
title={guideData.seo.title} title={guideData.seo.title}
description={guideData.seo.description} description={guideData.seo.description}
permalink={`/backend/${guideId}`} permalink={`/backend/${guideId}`}
canonicalUrl={guideData.canonicalUrl} canonicalUrl={guideData.canonicalUrl}
ogImageUrl={ogImageUrl}
> >
<GuideHeader guide={guide} /> <GuideHeader guide={guide} />

@ -7,7 +7,17 @@ import { getGuideById } from '../../lib/guide';
const guideId = 'backend-languages'; const guideId = 'backend-languages';
const guide = await getGuideById('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 || '',
},
)}`;
--- ---
<BaseLayout <BaseLayout
@ -15,8 +25,9 @@ const { frontmatter: guideData } = guide;
description={guideData.seo.description} description={guideData.seo.description}
permalink={`/backend/${guideId}`} permalink={`/backend/${guideId}`}
canonicalUrl={guideData.canonicalUrl} canonicalUrl={guideData.canonicalUrl}
ogImageUrl={ogImageUrl}
> >
<GuideHeader guide={guide} /> <GuideHeader guide={guide!} />
<div class='mx-auto max-w-[700px] py-5 sm:py-10'> <div class='mx-auto max-w-[700px] py-5 sm:py-10'>
<MarkdownFile> <MarkdownFile>

@ -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,
},
)}`;
--- ---
<BaseLayout <BaseLayout
permalink={`/best-practices/${bestPracticeId}`} permalink={`/best-practices/${bestPracticeId}`}
title={bestPracticeData?.seo?.title} title={bestPracticeData?.seo?.title}
briefTitle={bestPracticeData?.briefTitle} briefTitle={bestPracticeData?.briefTitle}
ogImageUrl={ogImageUrl}
description={bestPracticeData.seo.description} description={bestPracticeData.seo.description}
keywords={bestPracticeData.seo.keywords} keywords={bestPracticeData.seo.keywords}
noIndex={bestPracticeData.isUpcoming} noIndex={bestPracticeData.isUpcoming}

@ -21,7 +21,17 @@ export async function getStaticPaths() {
const { guideId } = Astro.params; const { guideId } = Astro.params;
const { guide } = Astro.props; const { guide } = Astro.props;
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 || '',
},
)}`;
--- ---
<BaseLayout <BaseLayout
@ -29,6 +39,7 @@ const { frontmatter: guideData } = guide;
description={guideData.seo.description} description={guideData.seo.description}
permalink={`/guides/${guideId}`} permalink={`/guides/${guideId}`}
canonicalUrl={guideData.canonicalUrl} canonicalUrl={guideData.canonicalUrl}
ogImageUrl={ogImageUrl}
> >
<GuideHeader guide={guide} /> <GuideHeader guide={guide} />

Loading…
Cancel
Save