-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from LoveYourself999/main
Adding video summaries for each conferences
- Loading branch information
Showing
4 changed files
with
150 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// pages/conferences/[conference_name].js | ||
|
||
import { useRouter } from 'next/router'; | ||
import Papa from 'papaparse'; | ||
|
||
export default function Conference({ conferences, allVideos }) { | ||
const router = useRouter(); | ||
|
||
if (router.isFallback) { | ||
return <div>Loading...</div>; | ||
} | ||
|
||
const sameConferences = allVideos.filter((video) => video.conference_name === conferences[0].conference_name); | ||
|
||
return ( | ||
<div className="container"> | ||
<h1>{conferences[0].conference_name}</h1> | ||
{sameConferences.map((conference, index) => ( | ||
<div key={index} className="conference"> | ||
<p><strong>Video ID:</strong> {conference.video_id}</p> | ||
<p><strong>Video Summary:</strong> {conference.summary}</p> | ||
<p>-------------------------</p> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
} | ||
|
||
export async function getStaticPaths() { | ||
try { | ||
const response = await fetch('https://raw.githubusercontent.com/cncf-tags/cloud-native-ai/main/cncf-youtube-channel-summarizer/data/cncf_video_summary_29.csv'); | ||
if (!response.ok) { | ||
throw new Error('Failed to fetch CSV'); | ||
} | ||
const csvText = await response.text(); | ||
const { data: videos } = Papa.parse(csvText, { header: true }); | ||
|
||
const paths = videos.map((video) => ({ | ||
params: { id: video.video_id }, | ||
})); | ||
|
||
return { | ||
paths, | ||
fallback: false, // or 'blocking' or true | ||
}; | ||
} catch (error) { | ||
console.error('Error fetching or parsing CSV:', error); | ||
return { | ||
paths: [], | ||
fallback: false, // or 'blocking' or true | ||
}; | ||
} | ||
} | ||
|
||
export async function getStaticProps({ params }) { | ||
try { | ||
const response = await fetch('https://raw.githubusercontent.com/cncf-tags/cloud-native-ai/main/cncf-youtube-channel-summarizer/data/cncf_video_summary_29.csv'); | ||
if (!response.ok) { | ||
throw new Error('Failed to fetch CSV'); | ||
} | ||
const csvText = await response.text(); | ||
const { data: videos } = Papa.parse(csvText, { header: true }); | ||
const conferences = videos.filter((video) => video.video_id === params.id); | ||
if (conferences.length === 0) { | ||
return { | ||
notFound: true, | ||
}; | ||
} | ||
|
||
return { | ||
props: { | ||
conferences, | ||
allVideos: videos, | ||
}, | ||
}; | ||
} catch (error) { | ||
console.error('Error fetching or parsing CSV:', error); | ||
return { | ||
notFound: true, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters