mime-icons
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

MIME icons

Give an icon to a web resource file by Content-Type or url subfix.

Usage

npm install mime-icons

First, MUST copy icons folder to your project's public files path.

Now, import module, with getIconName function, you will get the target icon name. The function get 2 optional parameters:

parameter from
contentType HTTP response header's Content-Type
url resource url

example:

import mime from "mime-icons";

const icon = mime.getIconName({
  contentType: "text/html",
  url: "http://xxx.com/index.html",
});

const imagePath = env.PUBLIC_PATH + "/icons/" + icon;

Example

git clone https://github.com/DeronW/mime-icons
cd mime-icons/demo
npm i
npm run dev
# open http://localhost:5173

Resources

Thanks to apache for content-type and file extensions mapping, and vscode-icons for extensions icons.

customize

Some files has common extension, use common use case overwrite it, such as js, css, html and soon.

Readme

Keywords

Package Sidebar

Install

npm i mime-icons

Weekly Downloads

14

Version

0.0.5

License

MIT

Unpacked Size

164 kB

Total Files

8

Last publish

Collaborators

  • delong