1.2.3 • Published 2 years ago

@backpackjs/head v1.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@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;
1.2.3

2 years ago

1.2.1

2 years ago

1.1.1

2 years ago

1.1.2

2 years ago

1.0.0

2 years ago

1.1.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.3

2 years ago

0.0.131

2 years ago

0.0.128

2 years ago

0.0.129

2 years ago

0.0.130

2 years ago

0.0.127

2 years ago

0.0.126

3 years ago

0.0.125

3 years ago

0.0.124

3 years ago

0.0.123

3 years ago

0.0.122

3 years ago

0.0.121

3 years ago

0.0.120

3 years ago

0.0.119

3 years ago

0.0.118

3 years ago

0.0.117

3 years ago

0.0.116

3 years ago

0.0.115

3 years ago

0.0.114

3 years ago

0.0.113

3 years ago

0.0.112

3 years ago

0.0.111

3 years ago

0.0.110

3 years ago

0.0.109

3 years ago

0.0.108

3 years ago

0.0.107

3 years ago

0.0.106

3 years ago

0.0.105

3 years ago

0.0.104

3 years ago

0.0.103

3 years ago

0.0.102

3 years ago

0.0.101

3 years ago

0.0.100

3 years ago

0.0.25

3 years ago

0.0.24

3 years ago

0.0.18

3 years ago

0.0.17

3 years ago

0.0.16

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago