-
-
Notifications
You must be signed in to change notification settings - Fork 741
Expand file tree
/
Copy pathgetExampleData.ts
More file actions
21 lines (18 loc) · 710 Bytes
/
getExampleData.ts
File metadata and controls
21 lines (18 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import {
ExampleData,
exampleGroupsData,
} from "@/components/example/generated/exampleGroupsData.gen";
export function getExampleData(
exampleGroupName: string,
exampleName: string,
): ExampleData {
const exampleData = exampleGroupsData
.find((exampleGroup) => exampleGroup.exampleGroupName === exampleGroupName)
?.examplesData.find((example) => example.exampleName === exampleName);
if (!exampleData) {
throw new Error(
`Example ${exampleGroupName}/${exampleName} could not be found in exampleGroupsData.gen.ts. Either an invalid example/group name was provided, or something went wrong when generating the exampleGroupsData.gen.ts file.`,
);
}
return exampleData;
}