teableio/teable

View on GitHub
apps/nextjs-app/src/features/app/utils/file.ts

Summary

Maintainability
A
0 mins
Test Coverage
import UnknownFileIcon from '@teable/ui-lib/icons/app/unknown-file.svg';
import { renderToString } from 'react-dom/server';

export const getFileCover = (mimetype: string, url: string) => {
  if (mimetype.startsWith('image/')) {
    return url;
  }
  return 'data:image/svg+xml,' + encodeURIComponent(renderToString(UnknownFileIcon()));
};