Skip to content

Commit 5370348

Browse files
RDoc-3729 Rebase fixes
1 parent 811e3e9 commit 5370348

12 files changed

Lines changed: 184 additions & 249 deletions

File tree

CLAUDE.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,18 +208,27 @@ category: "Ecommerce"
208208
license: "MIT License"
209209
license_url: "https://opensource.org/licenses/MIT"
210210
repository_url: "https://github.com/ravendb/sample-repo"
211+
demo_url: "https://demo.example.com"
211212
languages: ["C#"]
212213
gallery:
213214
- src: "/img/samples/my-sample/screenshot-1.webp"
214215
alt: "Main interface"
215216
- src: "/img/samples/my-sample/screenshot-2.webp"
216217
alt: "Admin dashboard"
218+
related_resources:
219+
- type: documentation
220+
documentation_type: docs
221+
subtitle: "Vector Search Overview"
222+
article_key: "ai-integration/vector-search/overview"
223+
- type: guide
224+
subtitle: "Related Guide Title"
225+
article_key: "guide-slug"
217226
---
218227
```
219228

220229
**Required fields**: `title`, `description`, `challenges_solutions_tags`, `feature_tags`, `tech_stack_tags`
221230

222-
**Optional fields**: `image`, `img_alt`, `category`, `license`, `license_url`, `repository_url`, `languages`, `gallery`
231+
**Optional fields**: `image`, `img_alt`, `category`, `license`, `license_url`, `repository_url`, `demo_url`, `languages`, `gallery`, `related_resources`
223232

224233
**SEO**: `repository_url` and `languages` feed `SoftwareSourceCode` JSON-LD schema for better search visibility.
225234

samples/the-ravens-library.mdx

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,23 @@ gallery:
1818
alt: "The Library of Ravens - Author Profile"
1919
- src: "/img/samples/library-of-ravens/03.webp"
2020
alt: "The Library of Ravens - User Profile"
21+
related_resources:
22+
- type: documentation
23+
documentation_type: docs
24+
subtitle: "Vector Search Overview"
25+
article_key: "ai-integration/vector-search/overview"
26+
- type: documentation
27+
documentation_type: docs
28+
subtitle: "Azure Storage Queues ETL"
29+
article_key: "server/ongoing-tasks/etl/queue-etl/azure-queue"
30+
- type: video
31+
subtitle: "Learn How to Build a Modern .NET App with ease: Azure Functions and Aspire with RavenDB"
32+
url: "https://www.youtube.com/watch?v=TEvBGNMSq9g"
2133
---
2234

23-
import { ActionsCard, RelatedResource, FeatureAccordion, SampleMetadataColumn, SampleLayout } from '@site/src/components/Samples';
24-
import Gallery from '@site/src/components/Common/Gallery';
25-
26-
export const sampleDetails = (
27-
<SampleMetadataColumn
28-
actionsCard={
29-
<ActionsCard
30-
githubUser="ravendb"
31-
githubRepo="samples-library"
32-
/>
33-
}
34-
relatedResources={
35-
<>
36-
<RelatedResource
37-
type="documentation"
38-
documentationType="docs"
39-
subtitle="Vector Search Overview"
40-
articleKey="ai-integration/vector-search/overview"
41-
/>
42-
<RelatedResource
43-
type="documentation"
44-
documentationType="docs"
45-
subtitle="Azure Storage Queues ETL"
46-
articleKey="server/ongoing-tasks/etl/queue-etl/azure-queue"
47-
/>
48-
</>
49-
}
50-
/>
51-
);
52-
53-
<SampleLayout details={sampleDetails} gallery={<Gallery images={frontMatter.gallery} />}>
35+
import { FeatureAccordion, SampleLayout } from '@site/src/components/Samples';
36+
37+
<SampleLayout>
5438

5539
## Overview
5640

src/components/Samples/Hub/Partials/SamplesGrid.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ export default function SamplesGrid({ samples, selectedTags, matchLogic, onTagCl
2828
});
2929
}, [samples, selectedTags, matchLogic]);
3030

31-
const sortedSamples = useMemo(() => {
32-
return filteredSamples;
33-
}, [filteredSamples]);
34-
35-
if (sortedSamples.length === 0) {
31+
if (filteredSamples.length === 0) {
3632
return (
3733
<div className="flex items-center justify-center py-12">
3834
<p className="text-center text-black/60 dark:text-white/60">No samples found matching your filters.</p>
@@ -54,11 +50,11 @@ export default function SamplesGrid({ samples, selectedTags, matchLogic, onTagCl
5450
"dark:bg-white/20 dark:text-white"
5551
)}
5652
>
57-
{sortedSamples.length}
53+
{filteredSamples.length}
5854
</span>
5955
</div>
6056
<div className={clsx("grid grid-cols-1 md:grid-cols-2 gap-4", "animate-in fade-in")}>
61-
{sortedSamples.map((sample) => (
57+
{filteredSamples.map((sample) => (
6258
<SampleCard
6359
key={sample.id}
6460
title={sample.title}

src/components/Samples/Hub/SamplesHomePage.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,6 @@ export default function SamplesHomePage() {
9191
setSelectedTags(newSelected);
9292
};
9393

94-
const handleTagClick = (tagKey: string) => {
95-
const newSelected = new Set(selectedTags);
96-
if (newSelected.has(tagKey)) {
97-
newSelected.delete(tagKey);
98-
} else {
99-
newSelected.add(tagKey);
100-
}
101-
setSelectedTags(newSelected);
102-
};
103-
10494
const { value: isFilterDrawerOpen, setTrue: openFilterDrawer, setFalse: closeFilterDrawer } = useBoolean(false);
10595

10696
const hasActiveFilters = selectedTags.size > 0 || matchLogic !== "any";
@@ -218,10 +208,10 @@ export default function SamplesHomePage() {
218208

219209
<div className="lg:col-span-3">
220210
<SamplesGrid
221-
samples={samples.filter((s) => s.id !== "home")}
211+
samples={filteredSamples}
222212
selectedTags={selectedTags}
223213
matchLogic={matchLogic}
224-
onTagClick={handleTagClick}
214+
onTagClick={handleTagToggle}
225215
/>
226216
</div>
227217
</div>

src/components/Samples/Overview/Partials/ActionsCard.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ import Button from "@site/src/components/Common/Button";
44

55
export interface ActionsCardProps {
66
className?: string;
7-
githubUser?: string;
8-
githubRepo?: string;
7+
githubUrl?: string;
98
demoUrl?: string;
109
}
1110

12-
export default function ActionsCard({ className, githubUser, githubRepo, demoUrl }: ActionsCardProps) {
13-
const githubUrl = githubUser && githubRepo ? `https://github.com/${githubUser}/${githubRepo}` : undefined;
11+
export default function ActionsCard({ className, githubUrl, demoUrl }: ActionsCardProps) {
1412

1513
return (
1614
<div

src/components/Samples/Overview/Partials/RelatedResource.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { IconName } from "@site/src/typescript/iconName";
55
import Link from "@docusaurus/Link";
66
import { useLatestVersion } from "@site/src/hooks/useLatestVersion";
77

8-
type ResourceType = "guide" | "documentation";
8+
type ResourceType = "guide" | "documentation" | "video";
99

1010
type DocumentationType = "docs" | "cloud";
1111

@@ -14,7 +14,8 @@ export interface RelatedResourceProps {
1414
type: ResourceType;
1515
documentationType?: DocumentationType;
1616
subtitle: string;
17-
articleKey: string;
17+
articleKey?: string;
18+
externalUrl?: string;
1819
}
1920

2021
const TYPE_CONFIG: Record<ResourceType, { title: string; icon: IconName }> = {
@@ -26,6 +27,10 @@ const TYPE_CONFIG: Record<ResourceType, { title: string; icon: IconName }> = {
2627
title: "Documentation",
2728
icon: "database",
2829
},
30+
video: {
31+
title: "Video Walkthrough",
32+
icon: "play",
33+
},
2934
};
3035

3136
export default function RelatedResource({
@@ -34,18 +39,23 @@ export default function RelatedResource({
3439
documentationType = "docs",
3540
subtitle,
3641
articleKey,
42+
externalUrl,
3743
}: RelatedResourceProps) {
3844
const latestVersion = useLatestVersion() as string;
3945
const config = TYPE_CONFIG[type];
4046

4147
const url = React.useMemo(() => {
48+
if (externalUrl) {
49+
return externalUrl;
50+
}
51+
4252
if (type === "guide") {
4353
return `/guides/${articleKey}`;
4454
}
4555

4656
const basePath = documentationType === "cloud" ? "/cloud" : `/${latestVersion}`;
4757
return `${basePath}/${articleKey}`;
48-
}, [type, documentationType, articleKey, latestVersion]);
58+
}, [type, documentationType, articleKey, externalUrl, latestVersion]);
4959

5060
const icon = type === "documentation" && documentationType === "cloud" ? "cloud" : config.icon;
5161

@@ -72,8 +82,12 @@ export default function RelatedResource({
7282
<Icon icon={icon} size="2xs" className="text-black dark:text-white" />
7383
</div>
7484
<div className="flex flex-col flex-1 min-w-0">
75-
<p className="text-sm leading-5 text-black dark:text-white !mb-0 truncate">{config.title}</p>
76-
<p className="text-xs leading-4 text-black/60 dark:text-white/60 !mb-0 truncate">{subtitle}</p>
85+
<p className="text-sm leading-5 text-black dark:text-white !mb-0 truncate" title={config.title}>
86+
{config.title}
87+
</p>
88+
<p className="text-xs leading-4 text-black/60 dark:text-white/60 !mb-0 truncate" title={subtitle}>
89+
{subtitle}
90+
</p>
7791
</div>
7892
</Link>
7993
);

src/components/Samples/Overview/Partials/SampleMetadataColumn.tsx

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import React, { ReactNode, useMemo } from "react";
1+
import React, { useMemo } from "react";
22
import { useDoc } from "@docusaurus/plugin-content-docs/client";
33
import { usePluginData } from "@docusaurus/useGlobalData";
44
import clsx from "clsx";
55
import Heading from "@theme/Heading";
66
import Tag from "@site/src/theme/Tag";
77
import type { PluginData } from "@site/src/components/Samples/types";
8+
import ActionsCard from "./ActionsCard";
9+
import RelatedResource from "./RelatedResource";
810

911
export interface SampleMetadataColumnProps {
1012
className?: string;
11-
actionsCard?: ReactNode;
12-
relatedResources?: ReactNode;
1313
}
1414

1515
interface 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,19 @@ 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) && (
108+
<ActionsCard githubUrl={repositoryUrl} demoUrl={demoUrl} />
109+
)}
105110

106111
<TagSection title="Challenges & Solutions" tags={challengesSolutionsTags} />
107112
<TagSection title="Feature" tags={featureTags} />
@@ -137,12 +142,23 @@ export default function SampleMetadataColumn({ className, actionsCard, relatedRe
137142
</div>
138143
)}
139144

140-
{relatedResources && (
145+
{relatedResourceItems && relatedResourceItems.length > 0 && (
141146
<div className="flex flex-col gap-2">
142147
<Heading as="h5" className="!mb-0 text-sm font-semibold">
143148
Related Resources
144149
</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>
146162
</div>
147163
)}
148164
</div>

src/components/Samples/Overview/SampleLayout.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import React, { ReactNode } from "react";
2+
import SampleMetadataColumn from "./Partials/SampleMetadataColumn";
3+
import Gallery from "@site/src/components/Common/Gallery";
4+
import { useDoc } from "@docusaurus/plugin-content-docs/client";
25

36
interface SampleLayoutProps {
47
children: ReactNode;
5-
details: ReactNode;
6-
gallery?: ReactNode;
78
}
89

9-
export default function SampleLayout({ children, details, gallery }: SampleLayoutProps) {
10+
export default function SampleLayout({ children }: SampleLayoutProps) {
11+
const { frontMatter } = useDoc();
12+
const gallery = frontMatter.gallery?.length ? <Gallery images={frontMatter.gallery} /> : null;
13+
1014
return (
1115
<div className="flex flex-col-reverse lg:flex-row flex-wrap gap-8">
1216
<div className="flex-1 min-w-0">
@@ -15,7 +19,7 @@ export default function SampleLayout({ children, details, gallery }: SampleLayou
1519
</div>
1620
<div className="lg:w-[300px] shrink-0">
1721
<div className="lg:hidden">{gallery}</div>
18-
{details}
22+
<SampleMetadataColumn />
1923
</div>
2024
</div>
2125
);

src/typescript/docMetadata.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ export interface GalleryImage {
88
alt?: string;
99
}
1010

11+
export interface RelatedResourceFrontMatter {
12+
type: "guide" | "documentation" | "video";
13+
documentation_type?: "docs" | "cloud";
14+
subtitle: string;
15+
article_key?: string;
16+
url?: string;
17+
}
18+
1119
export interface CustomDocFrontMatter extends DocFrontMatter {
1220
supported_languages?: DocsLanguage[];
1321
see_also?: SeeAlsoItemType[];
@@ -26,8 +34,10 @@ export interface CustomDocFrontMatter extends DocFrontMatter {
2634
license?: string;
2735
license_url?: string;
2836
repository_url?: string;
37+
demo_url?: string;
2938
languages?: string[];
3039
external_url?: string;
40+
related_resources?: RelatedResourceFrontMatter[];
3141
}
3242

3343
type CustomDocContextValue = Omit<DocContextValue, "frontMatter" | "metadata"> & {

0 commit comments

Comments
 (0)