Update and display talk teasers
One last thing to make the event page complete. The teasers on the page need to show talk teasers and link to associated talks.

Create the talk-lib file
Create the talk-lib.ts file so you have a dedicated function to query talk data.
To create the talk-lib file:
-
In Visual Studio Code, open the starter kit repository and go to the /lib/Events folder.
-
Create a copy of the event-lib.ts file and name it talk-lib.ts.
-
Open this file and modify it as shown in the following table and code sample.
Search for
Change from
Change to
Functions that use
Event
in the title.Event
Talk
import Event statement
import Event, {EventResults} from "../../types/Events/event-type";
(import Talk, { TalkResults } from "../../types/Events/talk-type";)
import Event
statementN/A
import ALL_AGENDA_QUERY, {AGENDA_QUERY} from "../../graphQl/Events/agenda-query";)
.getAllTalk
functionPromise Event[]
Promise Talk[]
.getAllTalk
functionALL_EVENT_QUERY
ALL_AGENDA_QUERY
to pass into the functiongetTalkById
functionPromise Event
Promise Talk
getTalkById
functionconst queryEvent
const queryTalk
getTalkById
functionawait fetchAPI(queryEvent)
await fetchAPI(queryTalk)
getAllEventsWithIds
functionPromise Event
Promise Talk
.getAllEventsWithIds
functiondata:allEvent
data:allTalk
getAllTalksWithIds
functionEVENT_QUERY
AGENDA_QUERY
extractPosts
functiondata:Event
data:Talk
extractPosts
functiondata:EventResults
data:TalkResults
extractPost
functiondata:Event
data:Talk
-
Remove unused imports for events.
-
Save the file. The final code looks like this.
Create the talkTeaser component file
To create the talkTeaser component file:
-
In Visual Studio Code, open the starter kit repository, make a copy of the /components/Recipe folder and name it Events.
-
Open the Events folder and rename the recipeTeaser-component.tsx file talkTeaser-component.tsx.
-
Open the talkTeaser-component.tsx file and change all mentions of recipe to equivalent mentions of talk.
-
Save the file. The final code looks like this.
Create the talk details page
Create the talk details pages so the talk IDs are passed through the URL and query for data.
To create the talk details page:
-
In Visual Studio Code, open the starter kit repository and go to the /pages folder.
-
Create a copy of the recipes folder and name it talk.
-
Open the /pages/talk/[slug].tsx file.
-
Modify it as follows to create the talk detail pages, changing all instances of recipe to equivalent instances of talk.
Search for
Change from
Change to
import Recipe
import Recipe, {RecipeResults} from "../../types/Recipe/recipe-type";
import Talk, {TalkResults} from "../../types/Events/talk-type";
import {getRecipeById
import {getRecipeById,getAllRecipeWithIds} from "../../lib/Recipe/recipe-lib";
import {getTalkById,getAllTalksWithIds} from "../../lib/Events/talk-lib";
getStaticProps
functionconst recipe
const talk
getStaticProps
functionget recidpeById
getTalkById
getStaticProps
functionprops: {recipe,homepage}
props: {talk,homepage}
getStaticPaths
functionconst allRecipePost
const allTalksPost
getStaticPaths
functiongetAllRecipesWithIds
getAllTalksWithIds
getStaticPaths
functionallRecipePosts.map(({ id }) =
/recipes/${id})
allTalkPosts.map(({ id }) =
/talk/${id})
props
definitionrecipe: Recipe
talk: Talk
Post
propertyrecipe
talk
title
tagsrecipe?.Title
talk?.talkTitle
HeroBanner
recipeImage (recipe?.image?.results[0].fileUrl)
talkImage (talk?.image?.results[0].fileUrl)
h1
tagh1 {recipe?.Title} /h1
h1 {talk?.talkTitle} /h1
strong Duration: /strong
{recipe?.Duration}
{talk?.time}
strong Ingredients: /strong
p strong Ingredients: /strong {recipe?.Ingredients}/p
Remove or comment out.
-
Remove
Output Duration
andIngredients
as these are not needed. -
Remove the
RichText Component
as this is not needed becausetalkDescription
is not rich text. -
Add
Talk Data
. The final code looks like this.
Update the event.tsx file
To update the event.tsx file:
-
In Visual Studio Code, open the starter kit repository and go to the /pages folder.
-
Open the event.tsx file.
-
Add the line
import TalkTeaserComponent from '../components/Talk/talkTeaser-component';
after theimport FooterComponent
statement. -
Add the following lines before the FooterComponent.
RequestResponseTalkTeaserComponent allTalks={event.agenda} /
-
Save the file.
-
If the website is not still running locally, run
npm run dev
. -
Navigate to
http://localhost:3000/event
to open the event page and see your changes.
The final code should look like this.
Your first foray into Content Hub ONE development is complete! You're now ready to continue your developer journey to build and deliver great applications.