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

set-meta

v0.4.3

Published

Setting html meta

Downloads

132

Readme

set-meta

Setting html meta.

Usage

import Meta from 'set-meta'

const meta = new Meta({
  lang: 'en',
  titleTemplate: '%s - Company Name',
  openGraph: {
    og: {
      site_name: 'Company Name'
    }
  }
})

meta.set({
  // <html lang="...">
  lang: 'en',

  // <title>
  title: 'Separate URLs',

  // <meta name="author" content="...">
  author: 'The Author Name',
  description: 'In this configuration, each desktop URL has an equivalent different URL serving mobile-optimized content.',

  // shortcut of openGraph.og.image
  image: 'https://developers.google.com/_static/14b311b77e/images/share/devsite-google-blue.png',

  // <meta name="keywords" content="...">
  keywords: ['seo', 'mobile'],

  // <link rel="canonical" content="...">
  canonicalURL: 'https://developers.google.com/search/mobile-sites/mobile-seo/separate-urls',

  // <link rel="alternate" hreflang="..." href="...">
  locales: [
    {
      hreflang: 'en',
      href: 'https://developers.google.com/search/mobile-sites/mobile-seo/separate-urls'
    },
    {
      hreflang: 'ar',
      href: 'https://developers.google.com/search/mobile-sites/mobile-seo/separate-urls?hl=ar'
    },
    {
      hreflang: 'x-default',
      href: 'https://developers.google.com/search/mobile-sites/mobile-seo/separate-urls'
    }
  ],

  // <link rel="alternate" media="..." href="...">
  media: [
    {
      media: 'only screen and (max-width: 640px)',
      href: 'http://m.example.com/page-1'
    }
  ],

  // extra <meta> tags
  extraMeta: [
    { 'http-equiv': 'Status', content: '200' },
    { 'http-equiv': 'Last-Modified', content: 'Sun, 23 Jul 2017 13:30:37 GMT' }
  ],

  // extra <link> tags
  extraLinks: [
    { rel: 'x-app-link', href: 'https://open-in-app.example.com/page-1' }
  ]
},

// Open Graph
// See https://github.com/kasha-io/set-open-graph
{
  og: {
    type: 'video.movie',
    locale: {
      current: 'en_US',
      alternate: [
        'zh_CN',
        'ja_JP'
      ]
    },
  },

  video: {
    director: [
      'http://examples.opengraphprotocol.us/profile.html',
      'http://examples.opengraphprotocol.us/profile2.html'
    ],
    actor: [
      {
        url: 'http://examples.opengraphprotocol.us/profile.html',
        role: 'Role in Move'
      }
    ],
    writer: [
      'http://examples.opengraphprotocol.us/profile.html'
    ],
    series: 'http://www.imdb.com/title/tt1520211/',
    release_date: '1895-12-28',
    duration: '50',
    tag: [
      'La Ciotat',
      'train'
    ]
  }
})

APIs

new Meta({ lang, titleTemplate, openGraph, customNS })

Creating an instance.

Params:
lang: Default lang attribute of <html>.
titleTemplate: Template of document title. e.g., '%s - Company Name', if you set the title to 'About', the document title would be 'About - Company Name'.
openGraph: Default open graph properties. See set-open-graph
customNS: Default custom namespace of open graph.

You can later change default options through properties:

  • this.lang
  • this.titleTamplate
  • this.openGraph (OpenGraph object, see set-open-graph)

meta.set(meta, openGraph, customNS)

Setting the document <meta> and <link>.

Params:
meta: Meta properties. See usage example for supported meta.
openGraph and customNS: See set-open-graph

meta.clear()

Removing the meta tags from document head.

License

MIT