|
1 | | -import React, { ReactNode, useMemo } from "react"; |
| 1 | +import React, { useMemo } from "react"; |
2 | 2 | import { useDoc } from "@docusaurus/plugin-content-docs/client"; |
3 | 3 | import { usePluginData } from "@docusaurus/useGlobalData"; |
4 | 4 | import clsx from "clsx"; |
5 | 5 | import Heading from "@theme/Heading"; |
6 | 6 | import Tag from "@site/src/theme/Tag"; |
7 | 7 | import type { PluginData } from "@site/src/components/Samples/types"; |
| 8 | +import ActionsCard from "./ActionsCard"; |
| 9 | +import RelatedResource from "./RelatedResource"; |
8 | 10 |
|
9 | 11 | export interface SampleMetadataColumnProps { |
10 | 12 | className?: string; |
11 | | - actionsCard?: ReactNode; |
12 | | - relatedResources?: ReactNode; |
13 | 13 | } |
14 | 14 |
|
15 | 15 | interface TagData { |
@@ -59,7 +59,7 @@ function TagSection({ title, tags }: TagSectionProps) { |
59 | 59 | ); |
60 | 60 | } |
61 | 61 |
|
62 | | -export default function SampleMetadataColumn({ className, actionsCard, relatedResources }: SampleMetadataColumnProps) { |
| 62 | +export default function SampleMetadataColumn({ className }: SampleMetadataColumnProps) { |
63 | 63 | const { frontMatter } = useDoc(); |
64 | 64 | const pluginData = usePluginData("recent-samples-plugin") as PluginData | undefined; |
65 | 65 |
|
@@ -94,14 +94,19 @@ export default function SampleMetadataColumn({ className, actionsCard, relatedRe |
94 | 94 | const category = frontMatter.category; |
95 | 95 | const license = frontMatter.license; |
96 | 96 | const licenseUrl = frontMatter.license_url; |
| 97 | + const repositoryUrl = frontMatter.repository_url; |
| 98 | + const demoUrl = frontMatter.demo_url; |
| 99 | + const relatedResourceItems = frontMatter.related_resources; |
97 | 100 |
|
98 | 101 | const challengesSolutionsTags = getTagsWithLabels(challengesSolutionsTagKeys, challengesSolutionsTagsData); |
99 | 102 | const featureTags = getTagsWithLabels(featureTagKeys, featureTagsData); |
100 | 103 | const techStackTags = getTagsWithLabels(techStackTagKeys, techStackTagsData); |
101 | 104 |
|
102 | 105 | return ( |
103 | 106 | <div className={clsx("sticky top-[90px] flex flex-col gap-4", className)}> |
104 | | - {actionsCard} |
| 107 | + {(repositoryUrl || demoUrl) && ( |
| 108 | + <ActionsCard githubUrl={repositoryUrl} demoUrl={demoUrl} /> |
| 109 | + )} |
105 | 110 |
|
106 | 111 | <TagSection title="Challenges & Solutions" tags={challengesSolutionsTags} /> |
107 | 112 | <TagSection title="Feature" tags={featureTags} /> |
@@ -137,12 +142,23 @@ export default function SampleMetadataColumn({ className, actionsCard, relatedRe |
137 | 142 | </div> |
138 | 143 | )} |
139 | 144 |
|
140 | | - {relatedResources && ( |
| 145 | + {relatedResourceItems && relatedResourceItems.length > 0 && ( |
141 | 146 | <div className="flex flex-col gap-2"> |
142 | 147 | <Heading as="h5" className="!mb-0 text-sm font-semibold"> |
143 | 148 | Related Resources |
144 | 149 | </Heading> |
145 | | - <div className="flex flex-col gap-1">{relatedResources}</div> |
| 150 | + <div className="flex flex-col gap-1"> |
| 151 | + {relatedResourceItems.map((resource, index) => ( |
| 152 | + <RelatedResource |
| 153 | + key={index} |
| 154 | + type={resource.type} |
| 155 | + documentationType={resource.documentation_type} |
| 156 | + subtitle={resource.subtitle} |
| 157 | + articleKey={resource.article_key} |
| 158 | + externalUrl={resource.url} |
| 159 | + /> |
| 160 | + ))} |
| 161 | + </div> |
146 | 162 | </div> |
147 | 163 | )} |
148 | 164 | </div> |
|
0 commit comments