--- import BestPracticeHeader from '../../../components/BestPracticeHeader.astro'; import FrameRenderer from '../../../components/FrameRenderer/FrameRenderer.astro'; import MarkdownFile from '../../../components/MarkdownFile.astro'; import ShareIcons from '../../../components/ShareIcons/ShareIcons.astro'; import { TopicDetail } from '../../../components/TopicDetail/TopicDetail'; import UpcomingForm from '../../../components/UpcomingForm.astro'; import BaseLayout from '../../../layouts/BaseLayout.astro'; import { UserProgressModal } from '../../../components/UserProgress/UserProgressModal'; import { generateArticleSchema } from '../../../lib/jsonld-schema'; import { getOpenGraphImageUrl } from '../../../lib/open-graph'; import { BestPracticeFileType, BestPracticeFrontmatter, getAllBestPractices, } from '../../../lib/best-practice'; export async function getStaticPaths() { const bestPractices = await getAllBestPractices(); return bestPractices.map((bestPractice: BestPracticeFileType) => ({ params: { bestPracticeId: bestPractice.id }, props: { bestPractice: bestPractice, }, })); } interface Params extends Record { bestPracticeId: string; } interface Props { bestPractice: BestPracticeFileType; } const { bestPracticeId } = Astro.params as Params; const { bestPractice } = Astro.props as Props; const bestPracticeData = bestPractice.frontmatter as BestPracticeFrontmatter; let jsonLdSchema = []; if (bestPracticeData.schema) { const bestPracticeSchema = bestPracticeData.schema; jsonLdSchema.push( generateArticleSchema({ url: `https://roadmap.sh/best-practices/${bestPracticeId}`, headline: bestPracticeSchema.headline, description: bestPracticeSchema.description, datePublished: bestPracticeSchema.datePublished, dateModified: bestPracticeSchema.dateModified, imageUrl: bestPracticeSchema.imageUrl, }), ); } const ogImageUrl = getOpenGraphImageUrl({ group: 'best-practices', resourceId: bestPracticeId, }); ---
{ !bestPracticeData.isUpcoming && bestPracticeData.jsonUrl && (
) } { !bestPracticeData.isUpcoming && !bestPracticeData.jsonUrl && ( ) }
{bestPracticeData.isUpcoming && }