added media to desktop board view

This commit is contained in:
plebbitor
2023-03-23 14:05:59 +01:00
parent 1cb69a75a5
commit 86a6672838
2 changed files with 72 additions and 7 deletions
+38
View File
@@ -0,0 +1,38 @@
import extName from 'ext-name';
const getCommentMediaInfo = (comment) => {
if (!comment?.thumbnailUrl && !comment?.link) {
return;
}
if (comment?.thumbnailUrl) {
return {
url: comment.link,
type: 'webpage'
};
}
if (comment?.link) {
const mime = extName(new URL(comment?.link).pathname.replace('/', ''))[0]?.mime
if (mime?.startsWith('image')) {
return {
url: comment.link,
type: 'image'
};
}
if (mime?.startsWith('video')) {
return {
url: comment.link,
type: 'video'
};
}
if (mime?.startsWith('audio')) {
return {
url: comment.link,
type: 'audio'
};
}
}
};
export default getCommentMediaInfo;