Implement the content types
To use the queried data, you map the content types that you created in Content Hub ONE with corresponding content types in the application.
To implement the content types:
-
In Visual Studio Code, open the starter kit repository and go to the /types folder.
-
Create a copy of the Recipe folder and name it Events.
-
In the Events folder, create two copies of the recipe-type.ts file. The recipe-type.ts file defines the model for the recipe object.
-
Name these three files speaker-type.ts, talk-type.ts, and event-type.ts.
-
Open each of the three files and modify them as shown in the following code samples, changing all mentions of recipes to the equivalent mentions of speaker, talk, or event. For each file, ensure the new text matches the case of the original.
import{MediaResults} from "../Common/media-type";
type Speaker = {
id: string
name: string
speakerName: string
speakerBio: string
speakerImage: MediaResults
// Content Hub ONE stores images as a list. This is a data type of a list of media assets.
}
export default Speaker
export type SpeakerResults = {
total: string;
results: Speaker[];
}
import {MediaResults} from "../Common/media-type"
import { SpeakerResults} from "./speaker-type";
type Talk = {
id: string
name: string
talkTitle: string
talkDescription: string
time: string
speaker: SpeakerResults
image: MediaResults
}
export default Talk
export type TalkResults = {
total: string;
results: Talk[];
}
import {MediaResults} from "../Common/media-type"
import { JSONContent } from "@tiptap/core";
import {TalkResults} from "./talk-type";
type Event = {
id: string
name: string
eventName: string
eventDescription: JSONContent
// The rich text field type results in a JSON output of the formatted text.
eventLocation: string
eventDate: Date
eventImage: MediaResults
agenda: TalkResults
}
export default Event
export type EventResults = {
total:string;
results: Event[];
}