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

@dbosoft/react-head

v0.2.0

Published

dbosoft web head component

Downloads

2

Readme

dbosoft Head

The dbosoft Head component lets you create a dbosoft branded <head> in NextJS projects.

npm install @dbosoft/react-head

Usage

// usage in custom documents
import { Head } from 'next/document'
import DBOHead from '@dbosoft/react-head'

<DBOHead is={Head} />

// becomes
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width" />
  <title>About | dbosoft</title>
  <meta http-equiv="x-ua-compatible" content="ie=edge" />
  <meta property="og:locale" content="en_US" />
  <meta property="og:type" content="website" />
  <meta property="article:publisher" content="https://www.facebook.com/dbosoft/"/>
  <meta name="twitter:site" content="@dbosoft" />
  <meta name="twitter:card" content="summary_large_image" />
</head>
// usage in pages
import Head from 'next/head'
import DBOHead from '@dbosoft/react-head'

<DBOHead is={Head} title="About | dbosoft" />

// becomes
<head>
  <meta charset="utf-8" />
  <title>About | dbosoft</title>
  <meta http-equiv="x-ua-compatible" content="ie=edge" />
  <meta name="viewport" content="width=device-width" />
  <meta property="og:locale" content="en_US" />
  <meta property="og:type" content="website" />
  <meta name="twitter:site" content="@dbosoft" />
  <meta name="twitter:card" content="summary_large_image" />
  <meta property="article:publisher" content="https://www.facebook.com/dbosoft/"/>
</head>

Props

is

The is prop defines the Head tag being used, which might be next/head or head from custom document.

import Document, { Html, Head, Main, NextScript } from 'next/document'
import DBOHead from '@dbosoft/react-head'

class MyDocument extends Document {
  static async getInitialProps(ctx) {
    const initialProps = await Document.getInitialProps(ctx)
    return { ...initialProps }
  }

  render() {
    return (
      <Html>
        <DBOHead is={Head} />
        <body>
          <Main />
          <NextScript />
        </body>
      </Html>
    )
  }
}

export default MyDocument

title

The title property sets page name used by the browser. It may include branding such as the site name.

<DBOHead is={Head} title="Page Name | Site Name" />

// becomes
<title>Page Name | Site Name</title>

For the external page name use the pageName property, which does not include any branding such as the site name. For the site name use the siteName property.

description

The description property sets the page description used externally.

<DBOHead is={Head} description="Page Description" />

// becomes
<meta property="og:description" name="description" content="Page Description">

image

The image property sets the page image used externally.

<DBOHead is={Head} image="/img/share/share.png" />

// becomes
<meta property="og:image" content="/img/share/share.png">

See https://developers.facebook.com/docs/sharing/webmasters/#basic for details and best practices.

pageName

The pageName property sets the page name used externally without any branding such as the site name.

<DBOHead is={Head} title="Page Title | dbosoft" pageName="Page Title" />

// becomes
<title>Page Title | dbosoft</title>
<meta property="og:title" content="Page Title" />

For the browser page name use the title property. For the site name use the siteName property.

See https://developers.facebook.com/docs/sharing/webmasters/#basic for details and best practices.

siteName

The siteName property sets site name used externally.

<DBOHead is={Head} siteName="dbosoft" />

// becomes
<meta property="og:site_name" content="dbosoft" />

See https://ogp.me/#optional for details.


presentational props

stylesheet

The stylesheet property defines one or more <link rel="stylesheet"> tags. Use it to add global styles to the page.

<DBOHead is={Head} stylesheet={[
  { href: '/css/critical.css' },
  { href: '/css/style.css' },
  { href: '/css/print.css', media: 'print' }
]} />

// becomes
<link rel="stylesheet" href="/css/critical.css">
<link rel="stylesheet" href="/css/style.css">
<link rel="stylesheet" href="/css/print.css" media="print">

preload

The preload property defines one or more <link rel="preload"> tags. Use it when you’ll need a resource soon.

<DBOHead is={Head} preload={[{
  href: '/css/style.css', as: 'style',
  href: '/fonts/gilmer/regular.woff2', as: 'font',
  href: '/videos/short', as: 'video', type: 'video/mp4'
}]} />

// becomes
<link rel="preload" href="/css/style.css" as="style">
<link rel="preload" href="/fonts/gilmer/regular.woff2" as="font">
<link rel="preload" href="/videos/short.mp4" as="video" type="video/mp4">

icon

The icon property defines one or more <link rel="icon"> tags.

<DBOHead is={Head} icon={[
  { href: '/favicon.ico', type: 'image/x-icon' },
  { href: '/favicon.gif', type: 'image/gif' },
  { href: '/[email protected]', sizes: '32x32' },
  { href: '/[email protected]', sizes: '64x64' }
]} />

// becomes
<link rel="icon" href="/favicon.ico" type="image/x-icon">
<link rel="icon" href="/favicon.gif" type="image/gif">
<link rel="icon" href="[email protected]" sizes="32x32">
<link rel="icon" href="[email protected]" sizes="64x64">

children

Additional children may also be appended as regular elements.

<DBOHead is={Head}>
  <meta property="article:section" content="Technology" />
</DBOHead>

// becomes
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width" />
  <title>About | dbosoft</title>
  <meta http-equiv="x-ua-compatible" content="ie=edge" />
  <meta property="og:locale" content="en_US" />
  <meta property="og:type" content="website" />
  <meta property="article:publisher" content="https://www.facebook.com/dbosoft/"/>
  <meta name="twitter:site" content="@dbosoft" />
  <meta name="twitter:card" content="summary_large_image" />
  <meta property="article:section" content="Technology" />
</head>