From 0bff81ca46856ea538041b13cc1c437883d5b78e Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 17 Nov 2022 06:16:12 +0000 Subject: [PATCH] Added meta data for websites --- src/pages/files/[fileId].js | 47 ++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/src/pages/files/[fileId].js b/src/pages/files/[fileId].js index 9c98147..3673296 100644 --- a/src/pages/files/[fileId].js +++ b/src/pages/files/[fileId].js @@ -7,8 +7,7 @@ import { getFileInfo } from "src/utils/helpers/fileHelpers"; import { formatBytes } from "src/utils/helpers/stringHelpers"; import { downloadURI } from "src/utils/helpers/webUtils"; -export default function File(props) { - const { isValidFile, fileData } = props; +export default function File({ isValidFile, fileData }) { const file = JSON.parse(fileData); let { uploader, @@ -21,9 +20,46 @@ export default function File(props) { height, ext, size, + isImage, + isVideo, } = file; - const metaData = ; + 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 = ( + + ); let toShow; if (!isValidFile) { @@ -44,8 +80,7 @@ export default function File(props) { ); } if (isValidFile) { - contentType = contentType.toLowerCase(); - if (contentType.includes("image")) { + if (isImage) { toShow = ( {fileId} ); } - if (contentType.includes("video")) { + if (isVideo) { toShow = ; } }