Giter Club home page Giter Club logo

hapi-favicon's Introduction

hapi-favicon

A simple hapi plugin that serves the favicon.ico route for you. This is the icon that will appear in browser tabs.

Installation

npm install hapi-favicon

Basic Icons

Just register the plugin with your hapi server:

 await server.register({
   plugin: require('hapi-favicon'),
   options: {
     path: '/path/to/standard/icons/standard.ico'
   }
 });

where path is the local file path to your favicon image. This will register a route with hapi at the standard /favicon.ico route that returns your icon with the image/x-icon mime header type. Leaving path blank will just serve a blank image.

Apple Touch Icons

You can tell hapi-favicon to also serve Apple touch icons for Apple-specific devices, in addition to the standard .ico icons:

 await server.register({
   plugin: require('hapi-favicon'),
   options: {
     path: '/path/to/standard/icons/standard.ico',
     appleTouch: '/path/to/apple/icons/'
   }
);

This will register a route at '/apple-touch-icon{size?}.png' that serves the corresponding PNG icon from the /path/to/apple/icons folder. Sizes supported are the Apple-standard dimensions: 57x57, 60x60, 72x72, 76x76, 114x114, 120x120, 144x144, 152x152. If the client requests dimensions other than these standard dimensions, the plugin will default to the next-lowest size. For example if you request /apple-touch-icon65x65.png, you will get the apple-touch-icon60x60.png icon instead.

Setting the appleTouch icon to true instead of a file path will result in the '/apple-touch-icon{size?}.png' route serving an empty image/x-icon for all requested image sizes.

Auth option

If you want your favicon.ico route to be protected by your hapi auth scheme, you can specify the auth config like so:

await server.register({
  plugin: require('hapi-favicon'),
  options: {
    path: '/path/to/standard/icons/standard.ico',
    auth: {
      strategy: 'cookie',
      mode: 'try'
    }
  }
);

This only applies to the favicon.ico route, Apple touch icons will be publicly available.

hapi-favicon's People

Contributors

jgallen23 avatar millette avatar orthagonal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.