fp/packages/next/app/components/vod-page.tsx

106 lines
4.9 KiB
TypeScript
Raw Normal View History

2024-01-20 16:16:14 +00:00
import { getUrl, getNextVod, getPreviousVod, getLocalizedDate } from '@/lib/vods';
import { IVod } from '@/lib/vods';
import Link from 'next/link';
import { VideoInteractive } from './video-interactive';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
2024-03-29 07:28:02 +00:00
import { faChevronLeft, faChevronRight, faGlobe, faImage, faLink } from "@fortawesome/free-solid-svg-icons";
2024-01-20 16:16:14 +00:00
import { notFound } from 'next/navigation';
import { IpfsCid } from './ipfs-cid';
import LinkableHeading from './linkable-heading';
2024-03-29 07:28:02 +00:00
import Image from 'next/image';
import Thumbnail from './thumbnail';
2024-01-20 16:16:14 +00:00
export function getVodTitle(vod: IVod): string {
2024-02-27 15:52:43 +00:00
// console.log('lets getVodTitle, ey?')
// console.log(JSON.stringify(vod, null, 2))
2024-03-29 07:28:02 +00:00
return vod.attributes?.title || vod.attributes?.announceTitle || `VOD ${vod.id}`
// return vod.attributes.title || vod.attributes.announceTitle || (vod.attributes?.date2 && vod.attributes?.vtuber?.data?.attributes?.displayName) ? `${vod.attributes.vtuber.data.attributes.displayName} ${vod.attributes.date2}` : `VOD ${vod.id}`;
2024-01-20 16:16:14 +00:00
}
export function buildMuxUrl(playbackId: string, token: string) {
return `https://stream.mux.com/${playbackId}.m3u8?token=${token}`
}
export function buildMuxSignedPlaybackId(playbackId: string, token: string) {
return `${playbackId}?token=${token}`
}
export function buildMuxThumbnailUrl(playbackId: string, token: string) {
return `https://image.mux.com/${playbackId}/storyboard.vtt?token=${token}`
}
export default async function VodPage({vod}: { vod: IVod }) {
2024-03-14 22:08:49 +00:00
// console.log('vod page helllo')
// console.log(vod)
2024-01-20 16:16:14 +00:00
if (!vod) notFound();
const slug = vod.attributes.vtuber.data.attributes.slug;
const previousVod = await getPreviousVod(vod);
const nextVod = await getNextVod(vod);
return (
<div className="container">
<div className="section pt-0">
<VideoInteractive vod={vod}></VideoInteractive>
2024-01-20 16:16:14 +00:00
{(vod.attributes.thumbnail) && (<div className='mb-5'>
<LinkableHeading text="Thumbnail Image" slug="thumb" icon={faImage}></LinkableHeading>
<Thumbnail url={vod.attributes.thumbnail.data.attributes.cdnUrl}></Thumbnail>
</div>)}
2024-03-29 07:28:02 +00:00
{(vod.attributes.videoSrcHash || vod.attributes.video240Hash) && (
<>
<LinkableHeading text="IPFS Content IDs" slug="ipfs" icon={faGlobe}></LinkableHeading>
{vod.attributes.videoSrcHash && (
<IpfsCid label="Source" cid={vod.attributes.videoSrcHash}></IpfsCid>
)}
{vod.attributes.video240Hash && (
<IpfsCid label="240p" cid={vod.attributes.video240Hash}></IpfsCid>
)}
</>
)}
2024-01-20 16:16:14 +00:00
<nav className="level mt-5">
<div className='level-left'>
<div className='level-item'>
{!!previousVod && (
<Link className='button' href={getUrl(previousVod, slug, previousVod.attributes.date2)}>
<FontAwesomeIcon
icon={faChevronLeft}
className='fas faChevronLeft'
></FontAwesomeIcon>
<span className="ml-2">Prev VOD {getLocalizedDate(previousVod)}</span>
</Link>
)}
</div>
</div>
<div className='level-center'>
<div className='level-item'>
<p className='has-text-grey-darker'>UID {vod.attributes.cuid}</p>
</div>
</div>
<div className='level-right'>
<div className='level-item'>
{!!nextVod && (
<Link className='button' href={getUrl(nextVod, slug, nextVod.attributes.date2)}>
<span className="mr-2">Next VOD {getLocalizedDate(nextVod)}</span>
<FontAwesomeIcon
icon={faChevronRight}
className='fas faChevronRight'
></FontAwesomeIcon>
</Link>
)}
</div>
</div>
</nav>
</div>
</div>
);
}