better file previews

This commit is contained in:
2025-07-13 13:33:14 +02:00
parent 596d7ac35d
commit b0628fe0bd
9 changed files with 71 additions and 33 deletions

View File

@@ -1,28 +1,41 @@
export function getFileIcon(fileType: string) {
if (fileType.startsWith('image/')) {
export function getFileIcon(mimeType: string | null) {
if (mimeType == null) {
return 'lucide:folder';
}
if (mimeType.startsWith('image/')) {
return 'lucide:file-image';
}
if (fileType.startsWith('video/')) {
if (mimeType.startsWith('video/')) {
return 'lucide:file-video-2';
}
if (fileType.startsWith('audio/')) {
if (mimeType.startsWith('audio/')) {
return 'lucide:file-audio-2';
}
if (fileType.startsWith('application/')) {
if (fileType === 'application/x-msdownload') {
if (mimeType.startsWith('application/')) {
if (mimeType === 'application/x-msdownload') {
return 'lucide:file-box';
}
if (fileType === 'application/json') {
if (mimeType === 'application/json') {
return 'lucide:file-json';
}
if (fileType === 'application/pdf') {
if (mimeType === 'application/pdf') {
return 'lucide:file-text';
}
if (mimeType === 'application/zip') {
return 'lucide:file-archive';
}
if (
mimeType === 'application/epub+zip' ||
mimeType === 'application/x-mobipocket-ebook'
) {
return 'lucide:file-text';
}
}
if (fileType === 'text/html') {
if (mimeType === 'text/html') {
return 'lucide:file-code';
}