Skip to content

Instantly share code, notes, and snippets.

@trickymast3r
Created December 30, 2018 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trickymast3r/44e069140d7351a6e78723e8d7b48be4 to your computer and use it in GitHub Desktop.
Save trickymast3r/44e069140d7351a6e78723e8d7b48be4 to your computer and use it in GitHub Desktop.
mime types by font awesome
import { findKey } from 'lodash';
const ICONS = {
'fa-font' : /font/,
'fa-file-image' : /image/,
'fa-file-audio' : /audio|application\/ogg/,
'fa-file-video' : /video/,
'fa-file-pdf' : /pdf/,
'fa-file-excel' : /excel|sheet/,
'fa-file-csv' : /csv/,
'fa-file-word' : /msword|opendocument/,
'fa-file-powerpoint': /presentation|powerpoint/,
'fa-file-code' : /application/,
'fa-file-alt' : /text\/plain/,
'fa-file-archive' : /zip|gzip/
};
function getFileIcon(type) {
let icon = findKey(ICONS,(i) => i.test(type));
if(!icon) return 'fa-file';
return icon;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment