fp/services/next/app/components/vod-nav.tsx

76 lines
3.2 KiB
TypeScript
Raw Normal View History

2024-01-20 16:16:14 +00:00
'use client';
import { faVideo, faExternalLinkAlt, faShareAlt } from "@fortawesome/free-solid-svg-icons";
import { faXTwitter } from '@fortawesome/free-brands-svg-icons';
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
2024-06-13 02:54:44 +00:00
import Image from "next/legacy/image";
2024-01-20 16:16:14 +00:00
import Link from 'next/link';
2024-07-10 22:11:18 +00:00
import { IVod } from '@/app/lib/vods';
import { buildIpfsUrl } from '@/app/lib/ipfs';
import { getSafeDate } from "@/app/lib/dates";
import { StreamButton } from '@/app/components/stream-button';
2024-01-20 16:16:14 +00:00
import VtuberButton from "./vtuber-button";
2024-03-14 22:08:49 +00:00
import { LocalizedDate } from "./localized-date";
2024-01-20 16:16:14 +00:00
export function getDownloadLink(cid: string, safeDate: string, slug: string, quality: string) {
return buildIpfsUrl(`${cid}?filename=${slug}-${safeDate}-${quality}.mp4`)
}
export interface IVodNavProps {
vod: IVod;
}
export default function VodNav ({ vod }: IVodNavProps) {
2025-01-11 03:10:04 +00:00
const safeDate = getSafeDate(vod.date_2);
2024-01-20 16:16:14 +00:00
return (
<nav className='level'>
<div className='level-left'>
<div className="level-item">
2025-01-11 03:10:04 +00:00
<Link href={`/vt/${vod.vtuber.slug}`}>
2024-01-20 16:16:14 +00:00
<VtuberButton
size="medium"
2025-01-11 03:10:04 +00:00
image={vod.vtuber.image}
displayName={vod.vtuber.display_name}
2024-01-20 16:16:14 +00:00
></VtuberButton>
</Link>
</div>
<div className="level-item">
2025-01-11 03:10:04 +00:00
{/* <StreamButton stream={vod.stream.data} /> */}
{vod.date_2}
2024-01-20 16:16:14 +00:00
</div>
</div>
<div className='level-right'>
2025-01-11 03:10:04 +00:00
{vod.ipfs_cid && (
2024-01-20 16:16:14 +00:00
<>
<div className='level-item'>
<Link
2025-01-11 03:10:04 +00:00
download={getDownloadLink(vod.ipfs_cid, safeDate, vod.vtuber.slug, 'source')}
2024-01-20 16:16:14 +00:00
className='button is-info is-small'
target="_blank"
prefetch={false}
2025-01-11 03:10:04 +00:00
href={getDownloadLink(vod.ipfs_cid, safeDate, vod.vtuber.slug, 'source')}
2024-01-20 16:16:14 +00:00
>
<FontAwesomeIcon icon={faVideo} className="fas fa-download mr-1" />
<span className='mr-1'>Source</span>
<FontAwesomeIcon icon={faExternalLinkAlt} className="fas fa-external-link-alt" />
</Link>
</div>
</>
)}
2025-01-11 03:10:04 +00:00
{vod.announce_url && (
2024-01-20 16:16:14 +00:00
<div className='level-item'>
<Link
target="_blank"
2025-01-11 03:10:04 +00:00
href={vod.announce_url}
2024-01-20 16:16:14 +00:00
className="button is-small"
>
<span className="mr-2"><FontAwesomeIcon icon={faXTwitter} className="fab fa-x-twitter" /></span><span><FontAwesomeIcon icon={faExternalLinkAlt} className="fas fa-external-link-alt" /></span>
</Link>
</div>
)}
</div>
</nav>
)
}