npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

next-favicon-loader

v3.0.5

Published

A favicon and manfiest generator module for Next.js with built-in webpack loader

Downloads

29

Readme

next-favicon-loader npm version license downloads

Features:

  • Favicon generator Uses the favicons package to generate favicons and manifests on all required platforms
  • Yaml config Put all your site config in one place in a site.yml file in your content folder
  • Single image input Generates everything off a single image and the site meta data for description, colors, etc.
  • Webpack loader Simple installation as Next.js plugin automatically installs a dedicated webpack loader for the favicon
  • Generates HTML helmet data Returns the HTML header links for all generated icons and manifest info
  • React generator The HTML header links are already React elements ready for you to insert using react-helmlet or next/head

Table of contents

Installation

npm install next-favicon-loader next-compose-plugins

Add the plugin with next-compose-plugins to your Next.js configuration:

// next.config.js
const withPlugins = require("next-compose-plugins");
const nextFaviconLoader = require("next-favicon-loader");

module.exports = withPlugins([
  nextFaviconLoader
  // your other plugins here
]);

Create a site properties file that includes a manifest section in yaml

// docs/_config/index.yml
---
:
manifest:
  appName: Novela by Narative
  appShortName: Novela
  appDescription: Novela by Narative
  start_url: /
  background: "#fff"
  theme_color: "#fff"   
  display: standalone
  alwaysEmitFull: false
:

Options

| Option | Type | Description | | :--- | :--: | :---------- | | meta | object | The contents of the file containing the site meta data | | file | string |The folder where theme files including favicon are kept | | file | string |The absolute filename including path and extension of the base favicon used for generating |

Usage

You can now simply create a single 512x512 or 1024x1024 png file of your favicon, require it in at least one place on both client and server side logic in your Next.js app with a special ?favicon resourceQuery, and in Dev mode a simple favicon will be set (with updating hashname so you can see the updates on refresh) and in production builds a full set of icons and browser manifest will be generated and the associated HTML react components returned

Example on client side

// pages/_app.tsx
import '@/docs/assets/favicon.png?favicon'
// .. rest of _app file goes here

Example on server side

/// pages/_document.tsx

import React from 'react'
import Document, { Html, Head, Main, NextScript } from 'next/document'
import Meta from '@/docs/assets/favicon.png?favicon'

export default class MyDocument extends Document {
  render(): JSX.Element {
    return (
      <Html lang="en">
        <Head>{Meta}</Head>
        <body>
          <Main />
          <NextScript />
        </body>
      </Html>
    )
  }
}
// tsconfig.json
    "baseUrl": ".",
    "paths": {
      "@/docs/*": [
        "./docs/*"
      ]
// global.d.ts
type FaviconData = Array<any>

declare module '*.png?favicon' {
  const content: FaviconData

  export default content
}

License

Licensed under the MIT license.

© Copyright Guy Barnard and Tinia Labs contributors