--- 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 { type BestPracticeFileType, type BestPracticeFrontmatter, getAllBestPractices, } from '../../../lib/best-pratice'; import { generateArticleSchema } from '../../../lib/jsonld-schema'; 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 = `${import.meta.env.PUBLIC_API_URL}/v1-open-graph?${new URLSearchParams( { type: 'roadmap', title: bestPracticeData.title, description: bestPracticeData.description, }, )}`; ---
{ !bestPracticeData.isUpcoming && bestPracticeData.jsonUrl && (
) } { !bestPracticeData.isUpcoming && !bestPracticeData.jsonUrl && ( ) }
{bestPracticeData.isUpcoming && }