0.0.5 • Published 8 months ago

mime-icons v0.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

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:

parameterfrom
contentTypeHTTP response header's Content-Type
urlresource 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.

0.0.5

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago

0.0.0-alpha-2

9 months ago

0.0.0-alpha

9 months ago