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

@backpackjs/head

v1.2.3

Published

A pre build-time backpack plugin that auto generates and writes multiple head react components to `storefront/src/head` on every build.

Downloads

160

Readme

@backpackjs/head

A pre build-time backpack plugin that auto generates and writes multiple head react components to storefront/src/head on every build.

This plugin is executed by @backpackjs/nextjs-backpack-init

The components structure is derived based on the configuration provided .via /backpack.head.js(or its default config). These global components are also already pre-imported in the projectsrc/head/index.jsx` component which is included in the via next/head

React components generated:

  • Metas.jsx - title, description etc..
  • Fonts.jsx - Custom or/and google font faces and link tags
  • Preconnects.jsx - dns-prefetches and pre-connects
  • Libs.jsx - and tags for all js and css third-party defined in the configuration

Example Fonts.jsx

/*
	This component is auto-generated by 🎒 Backpack.
	Any changes made will be overwritten in the next yarn build or dev.
	Please define your custom head configuration at backpack.head.js
*/
import React from 'react'
import Head from 'next/head'

const HeadFonts = () => (
<Head>
	{[
	[
		"link",
		{
			"key": "AvenirNext-Regular.woff",
			"rel": "preload",
			"as": "font",
			"crossOrigin": "anonymous",
			"href": "/fonts/AvenirNext-Regular.woff"
		}
	],
	[
		"link",
		{
			"key": "AvenirNext-Regular.woff2",
			"rel": "preload",
			"as": "font",
			"crossOrigin": "anonymous",
			"href": "/fonts/AvenirNext-Regular.woff2"
		}
	],
	[
		"link",
		{
			"key": "AvenirNext-Demi.woff2",
			"rel": "preload",
			"as": "font",
			"crossOrigin": "anonymous",
			"href": "/fonts/AvenirNext-Demi.woff2"
		}
	],
  ...
	[
		"link",
		{
			"key": "font-stylesheet",
			"rel": "stylesheet",
			"href": "/fonts/fonts.css"
		}
	]
].map(font => React.createElement(...font))
}
</Head>
);

export default HeadFonts;

Example Metas.jsx

/*
	This component is auto-generated by 🎒 Backpack.
	Any changes made will be overwritten in the next yarn build or dev.
	Please define your custom head configuration at backpack.head.js
*/
import React from 'react'
import Head from 'next/head'

const HeadMetas = () => (
<Head>
	{[
	[
		"meta",
		{
			"key": "viewport-meta",
			"name": "viewport",
			"content": "width=device-width, initial-scale=1"
		}
	],
	[
		"title",
		{
			"key": "site-title",
			"children": "Backpack Storefront"
		}
	],
	[
		"meta",
		{
			"key": "description",
			"name": "description",
			"content": "This is Backpack Storefront."
		}
	],
	[
		"meta",
		{
			"key": "http-equiv",
			"httpEquiv": "Content-Type",
			"content": "text/html; charset=utf-8"
		}
	],
	[
		"meta",
		{
			"key": "keywords",
			"name": "keywords",
			"content": "Backpack Storefront Clothing PackDigital backpack storefront"
		}
	],
	[
		"link",
		{
			"key": "shortcut icon",
			"rel": "shortcut icon",
			"href": "/favicon.png"
		}
	],
	[
		"link",
		{
			"key": "author",
			"rel": "author",
			"href": "https://packdigital.com"
		}
	],
	[
		"link",
		{
			"key": "canonical",
			"rel": "canonical",
			"href": "https://backpack-storefront.myshopify.com"
		}
	],
	[
		"meta",
		{
			"key": "default-generator",
			"name": "generator",
			"content": "Backpack Storefront"
		}
	],
	[
		"meta",
		{
			"key": "default-all-search-engines-crawling",
			"name": "robots",
			"content": "index,follow"
		}
	],
	[
		"meta",
		{
			"key": "default-google-engine-crawling",
			"name": "googlebot",
			"content": "index,follow"
		}
	],
	[
		"meta",
		{
			"key": "default-subject",
			"name": "subject",
			"content": "PackDigital backpack storefront"
		}
	]
].map(meta => React.createElement(...meta))
}
</Head>
);

export default HeadMetas;

Example Libs.jsx

/*
	This component is auto-generated by 🎒 Backpack.
	Any changes made will be overwritten in the next yarn build or dev.
	Please define your custom head configuration at backpack.head.js
*/
import React from 'react'
import Head from 'next/head'

const Libs = () => (
<Head>
	{[
	[
		"script",
		{
			"type": "text/javascript",
			"key": "gtm-dataLayer-js",
			"id": "gtm-dataLayer-js",
			"dangerouslySetInnerHTML": {
				"__html": "\n              window.dataLayer = [];\n              console.log('GTM dataLayer instantiated.');\n            "
			}
		}
	],
	[
		"script",
		{
			"type": "text/javascript",
			"key": "gtm-script-js",
			"id": "gtm-script-js",
			"dangerouslySetInnerHTML": {
				"__html": "\n                  console.warn('GTM script not initialized. Please provide a GTM_CONTAINER_ID');\n                "
			}
		}
	]
]	.map(lib => React.createElement(...lib))
}
</Head>
);

export default Libs;

Example Preconnects.jsx

/*
	This component is auto-generated by 🎒 Backpack.
	Any changes made will be overwritten in the next yarn build or dev.
	Please define your custom head configuration at backpack.head.js
*/
import React from 'react'
import Head from 'next/head'

const HeadPreconnects = () => (
<Head>
	{[
	[
		"link",
		{
			"key": "https://cdn.shopify.com/-prefetch",
			"rel": "dns-prefetch",
			"href": "https://cdn.shopify.com/"
		}
	],
	[
		"link",
		{
			"key": "https://cdn.shopify.com/-preconnect",
			"rel": "preconnect",
			"href": "https://cdn.shopify.com/",
			"crossOrigin": "anonymous"
		}
	],
	[
		"link",
		{
			"key": "https://monorail-edge.shopifysvc.com/-prefetch",
			"rel": "dns-prefetch",
			"href": "https://monorail-edge.shopifysvc.com/"
		}
	],
	[
		"link",
		{
			"key": "https://monorail-edge.shopifysvc.com/-preconnect",
			"rel": "preconnect",
			"href": "https://monorail-edge.shopifysvc.com/",
			"crossOrigin": "anonymous"
		}
	],
	[
		"link",
		{
			"key": "https://www.googletagmanager.com/-prefetch",
			"rel": "dns-prefetch",
			"href": "https://www.googletagmanager.com/"
		}
	],
	[
		"link",
		{
			"key": "https://www.googletagmanager.com/-preconnect",
			"rel": "preconnect",
			"href": "https://www.googletagmanager.com/",
			"crossOrigin": "anonymous"
		}
	],
	[
		"link",
		{
			"key": "https://googleads.g.doubleclick.net/-prefetch",
			"rel": "dns-prefetch",
			"href": "https://googleads.g.doubleclick.net/"
		}
	],
	[
		"link",
		{
			"key": "https://googleads.g.doubleclick.net/-preconnect",
			"rel": "preconnect",
			"href": "https://googleads.g.doubleclick.net/",
			"crossOrigin": "anonymous"
		}
	],
	[
		"link",
		{
			"key": "https://www.googleadservices.com/-prefetch",
			"rel": "dns-prefetch",
			"href": "https://www.googleadservices.com/"
		}
	],
	[
		"link",
		{
			"key": "https://www.googleadservices.com/-preconnect",
			"rel": "preconnect",
			"href": "https://www.googleadservices.com/",
			"crossOrigin": "anonymous"
		}
	],
	[
		"link",
		{
			"key": "https://www.google-analytics.com/-prefetch",
			"rel": "dns-prefetch",
			"href": "https://www.google-analytics.com/"
		}
	],
	[
		"link",
		{
			"key": "https://www.google-analytics.com/-preconnect",
			"rel": "preconnect",
			"href": "https://www.google-analytics.com/",
			"crossOrigin": "anonymous"
		}
	]
  ...
].map(preconnect => React.createElement(...preconnect))
}
</Head>
);

export default HeadPreconnects;