Skip to content

Commit bd7e265

Browse files
authored
docs: DEV-only examples (for drafts & tests) (#1685)
1 parent 8576384 commit bd7e265

File tree

187 files changed

+39
-33
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

187 files changed

+39
-33
lines changed

apps/typegpu-docs/src/components/ExampleCard.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ export function ExampleCard({ example }: { example: Example }) {
3535
</h3>
3636
{example.metadata.tags && example.metadata.tags.length > 0 && (
3737
<div className='flex flex-wrap gap-1'>
38+
{example.metadata.dev && (
39+
<span className='rounded-full bg-rose-700 px-2 py-1 text-white text-xs'>
40+
DEV
41+
</span>
42+
)}
3843
{example.metadata.tags.map((tag: string) => (
3944
<span
4045
key={tag}

apps/typegpu-docs/src/components/ExamplePage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useAtomValue, useSetAtom } from 'jotai';
22
import { Suspense, useEffect, useRef } from 'react';
33
import { currentExampleAtom } from '../utils/examples/currentExampleAtom.ts';
4-
import { examples } from '../utils/examples/exampleContent.ts';
4+
import { examples } from '../examples/exampleContent.ts';
55
import { ExampleNotFound } from './ExampleNotFound.tsx';
66
import { ExampleView } from './ExampleView.tsx';
77

apps/typegpu-docs/src/components/SearchableExampleList.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Fuse from 'fuse.js';
22
import { useEffect, useMemo, useRef, useState } from 'react';
3-
import { examples } from '../utils/examples/exampleContent.ts';
3+
import { examples } from '../examples/exampleContent.ts';
44
import { type Example, exampleCategories } from '../utils/examples/types.ts';
55
import { ExampleCard } from './ExampleCard.tsx';
66

@@ -12,6 +12,9 @@ function ExamplesGrid({ examples }: { examples: Example[] }) {
1212
);
1313
}
1414

15+
const DEV = globalThis.process.env.NODE_ENV === 'development';
16+
const TEST = globalThis.process.env.NODE_ENV === 'test';
17+
1518
export function SearchableExampleList(
1619
{ excludeTags = [], scrollContainerRef }: {
1720
excludeTags?: string[];
@@ -23,7 +26,8 @@ export function SearchableExampleList(
2326
const allExamples = useMemo(
2427
() =>
2528
Object.values(examples).filter((ex) =>
26-
!ex.metadata.tags?.some((tag) => excludeTags.includes(tag))
29+
!ex.metadata.tags?.some((tag) => excludeTags.includes(tag)) &&
30+
(DEV || TEST || !ex.metadata.dev)
2731
),
2832
[excludeTags],
2933
);

0 commit comments

Comments
 (0)