1- import React , { ReactNode , useMemo } from "react" ;
1+ import React , { useMemo } from "react" ;
22import { useDoc } from "@docusaurus/plugin-content-docs/client" ;
33import { usePluginData } from "@docusaurus/useGlobalData" ;
44import clsx from "clsx" ;
55import Heading from "@theme/Heading" ;
66import Tag from "@site/src/theme/Tag" ;
77import type { PluginData } from "@site/src/components/Samples/types" ;
8+ import ActionsCard from "./ActionsCard" ;
9+ import RelatedResource from "./RelatedResource" ;
810
911export interface SampleMetadataColumnProps {
1012 className ?: string ;
11- actionsCard ?: ReactNode ;
12- relatedResources ?: ReactNode ;
1313}
1414
1515interface TagData {
@@ -59,7 +59,7 @@ function TagSection({ title, tags }: TagSectionProps) {
5959 ) ;
6060}
6161
62- export default function SampleMetadataColumn ( { className, actionsCard , relatedResources } : SampleMetadataColumnProps ) {
62+ export default function SampleMetadataColumn ( { className } : SampleMetadataColumnProps ) {
6363 const { frontMatter } = useDoc ( ) ;
6464 const pluginData = usePluginData ( "recent-samples-plugin" ) as PluginData | undefined ;
6565
@@ -94,14 +94,17 @@ export default function SampleMetadataColumn({ className, actionsCard, relatedRe
9494 const category = frontMatter . category ;
9595 const license = frontMatter . license ;
9696 const licenseUrl = frontMatter . license_url ;
97+ const repositoryUrl = frontMatter . repository_url ;
98+ const demoUrl = frontMatter . demo_url ;
99+ const relatedResourceItems = frontMatter . related_resources ;
97100
98101 const challengesSolutionsTags = getTagsWithLabels ( challengesSolutionsTagKeys , challengesSolutionsTagsData ) ;
99102 const featureTags = getTagsWithLabels ( featureTagKeys , featureTagsData ) ;
100103 const techStackTags = getTagsWithLabels ( techStackTagKeys , techStackTagsData ) ;
101104
102105 return (
103106 < div className = { clsx ( "sticky top-[90px] flex flex-col gap-4" , className ) } >
104- { actionsCard }
107+ { ( repositoryUrl || demoUrl ) && < ActionsCard githubUrl = { repositoryUrl } demoUrl = { demoUrl } /> }
105108
106109 < TagSection title = "Challenges & Solutions" tags = { challengesSolutionsTags } />
107110 < TagSection title = "Feature" tags = { featureTags } />
@@ -123,11 +126,7 @@ export default function SampleMetadataColumn({ className, actionsCard, relatedRe
123126 </ Heading >
124127 < p className = "text-sm text-black dark:text-white !mb-0" >
125128 { licenseUrl ? (
126- < a
127- href = { licenseUrl }
128- target = "_blank"
129- rel = "noopener noreferrer"
130- >
129+ < a href = { licenseUrl } target = "_blank" rel = "noopener noreferrer" >
131130 { license }
132131 </ a >
133132 ) : (
@@ -137,12 +136,23 @@ export default function SampleMetadataColumn({ className, actionsCard, relatedRe
137136 </ div >
138137 ) }
139138
140- { relatedResources && (
139+ { relatedResourceItems && relatedResourceItems . length > 0 && (
141140 < div className = "flex flex-col gap-2" >
142141 < Heading as = "h5" className = "!mb-0 text-sm font-semibold" >
143142 Related Resources
144143 </ Heading >
145- < div className = "flex flex-col gap-1" > { relatedResources } </ div >
144+ < div className = "flex flex-col gap-1" >
145+ { relatedResourceItems . map ( ( resource , index ) => (
146+ < RelatedResource
147+ key = { index }
148+ type = { resource . type }
149+ documentationType = { resource . documentation_type }
150+ subtitle = { resource . subtitle }
151+ articleKey = { resource . article_key }
152+ externalUrl = { resource . url }
153+ />
154+ ) ) }
155+ </ div >
146156 </ div >
147157 ) }
148158 </ div >
0 commit comments