Added meta data for websites

This commit is contained in:
Lee 2022-11-17 06:16:12 +00:00
parent 5cd3594695
commit 0bff81ca46
No known key found for this signature in database
GPG Key ID: 6EA25896ECCB3121

@ -7,8 +7,7 @@ import { getFileInfo } from "src/utils/helpers/fileHelpers";
import { formatBytes } from "src/utils/helpers/stringHelpers"; import { formatBytes } from "src/utils/helpers/stringHelpers";
import { downloadURI } from "src/utils/helpers/webUtils"; import { downloadURI } from "src/utils/helpers/webUtils";
export default function File(props) { export default function File({ isValidFile, fileData }) {
const { isValidFile, fileData } = props;
const file = JSON.parse(fileData); const file = JSON.parse(fileData);
let { let {
uploader, uploader,
@ -21,9 +20,46 @@ export default function File(props) {
height, height,
ext, ext,
size, size,
isImage,
isVideo,
} = file; } = file;
const metaData = <NextSeo title={`${fileId}.${ext}`} />; let imageOrVideo;
if (isValidFile) {
if (isImage) {
imageOrVideo = {
images: [
{
url: fileUrl,
height: height,
width: width,
},
],
};
}
if (isVideo) {
imageOrVideo = {
videos: [
{
url: fileUrl,
height: height,
width: width,
},
],
};
}
}
const metaData = (
<NextSeo
title={isValidFile ? `${fileId}.${ext}` : "Invalid file"}
noindex
openGraph={imageOrVideo}
twitter={{
cardType: "large_summary",
}}
/>
);
let toShow; let toShow;
if (!isValidFile) { if (!isValidFile) {
@ -44,8 +80,7 @@ export default function File(props) {
); );
} }
if (isValidFile) { if (isValidFile) {
contentType = contentType.toLowerCase(); if (isImage) {
if (contentType.includes("image")) {
toShow = ( toShow = (
<Image <Image
alt={fileId} alt={fileId}
@ -56,7 +91,7 @@ export default function File(props) {
></Image> ></Image>
); );
} }
if (contentType.includes("video")) { if (isVideo) {
toShow = <video alt={fileId} src={fileUrl} controls></video>; toShow = <video alt={fileId} src={fileUrl} controls></video>;
} }
} }