-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fbff144
commit 0f5a0eb
Showing
11 changed files
with
101 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,4 +73,4 @@ | |
"tsx": "^4.19.3", | ||
"typescript": "^5.7.3" | ||
} | ||
} | ||
} |
File renamed without changes.
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,68 @@ | ||
import FileVideoPlayer from "@/components/file/video-player"; | ||
import { env } from "@/lib/env"; | ||
import { getFileById } from "@/lib/helpers/file"; | ||
import { getFileName } from "@/lib/utils/file"; | ||
import { Metadata } from "next"; | ||
import { notFound } from "next/navigation"; | ||
|
||
type FilePageProps = { | ||
params: Promise<{ | ||
id: string; | ||
}>; | ||
}; | ||
|
||
export async function generateMetadata({ | ||
params, | ||
}: FilePageProps): Promise<Metadata> { | ||
const { id } = await params; | ||
const fileMeta = await getFileById(id); | ||
if (!fileMeta) { | ||
return notFound(); | ||
} | ||
|
||
const fileName = getFileName(fileMeta); | ||
|
||
return { | ||
description: undefined, // remove it for now | ||
openGraph: { | ||
title: fileName, | ||
images: { | ||
url: `${env.NEXT_PUBLIC_WEBSITE_URL}/${fileName}`, | ||
}, | ||
}, | ||
twitter: { | ||
// Large image | ||
card: "summary_large_image", | ||
}, | ||
}; | ||
} | ||
|
||
export default async function FilePage({ params }: FilePageProps) { | ||
const { id } = await params; | ||
const fileMeta = await getFileById(id); | ||
if (!fileMeta) { | ||
return notFound(); | ||
} | ||
|
||
const url = `/${getFileName(fileMeta)}`; | ||
const isImage = fileMeta.mimeType.startsWith("image"); | ||
const isVideo = fileMeta.mimeType.startsWith("video"); | ||
|
||
return ( | ||
<div className="flex w-full text-center justify-center"> | ||
<div className="bg-secondary/70 p-2 w-full md:w-4xl rounded-md flex flex-col items-center"> | ||
<span className="text-xl font-semibold">{getFileName(fileMeta)}</span> | ||
|
||
{isImage && ( | ||
<img | ||
src={url} | ||
alt={`Image for ${getFileName(fileMeta)}`} | ||
className="max-h-[70vh]" | ||
/> | ||
)} | ||
|
||
{isVideo && <FileVideoPlayer url={url} className="max-h-[70vh]" />} | ||
</div> | ||
</div> | ||
); | ||
} |
1 change: 0 additions & 1 deletion
1
.../(pages)/(files)/thumbnails/[id]/route.ts → ...s)/(app)/(files)/thumbnails/[id]/route.ts
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
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
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
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,20 @@ | ||
"use client"; | ||
|
||
import ReactPlayer from "react-player"; | ||
|
||
type VideoPlayerProps = { | ||
url: string; | ||
className?: string; | ||
}; | ||
|
||
export default function FileVideoPlayer({ url, className }: VideoPlayerProps) { | ||
return ( | ||
<ReactPlayer | ||
url={url} | ||
volume={0.25} | ||
playing | ||
controls | ||
className={className} | ||
/> | ||
); | ||
} |
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