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

@wbe/metas-manager

v2.3.0

Published

Metas manager allow to inject new metas value in HTML metas tags on demand

Downloads

23

Readme

@wbe/metas-manager

Metas manager allow to inject new metas value in HTML metas tags on demand"

Installation

$ npm install -s @wbe/metas-manager

How to use

First, if your html page don't have a <title></title> meta tag, you need to set it. MetasManager need a document title tag to create others.

import { MetasManager } from "@wbe/metas-manager";

const values = {
 title: "Hello world!",
 description: "Custom description",
 imageUrl: "Custom preview image URL",
 siteName: "Custom site name",
 pageUrl: "Custom page URL",
 author: "Custom site Author",
 keywords: "Custom, key, words",
}

MetasManager.inject({ values });

This will inject new metas data in theses meta tags:

<head>
  <title>Hello world!</title>
  ...
  <meta property="og:title" content="Hello world!" auto-generated />
  <meta name="twitter:title" content="Hello world!" auto-generated />
  <meta name="description" content="Custom description" auto-generated />
  <meta property="og:description" content="Custom description" auto-generated />
  <meta name="twitter:description" content="Custom description" auto-generated />
  <meta property="og:image" content="Custom preview image URL" auto-generated />
  <meta name="twitter:image" content="Custom preview image URL" auto-generated />
  <meta rel="image_src" href="Custom preview image URL" auto-generated />
  <meta property="og:site_name" content="Custom site name" auto-generated />
  <meta name="twitter:site" content="Custom site name" auto-generated />
  <meta property="og:url" content="Custom page URL" auto-generated />
  <meta name="twitter:url" content="Custom page URL" auto-generated />
  <meta name="author" content="Custom site Author" auto-generated />
  <meta name="keywords" content="Custom, key, words" auto-generated />
</head>

This meta markup can be extend by adding new properties to default meta tags:

ex:

import MetasManager, { TMetaTags, TTag } from "@wbe/metas-manager";

const robotsTag: TMetaTags<TTag[]> = [
  // allow to create <meta name="robots" content="" auto-generated />
  { selectorAttr: "name", selectorValue: "robots", attr: "content" },
];

const tags = {
  ...MetasManager.DEFAULT_META_TAGS,
  robotsTag,
};

const values = {
 robots: "index,follow",
}

// will inject value in content attr: <meta name="robots" content="index,follow" auto-generated />
MetasManager.inject({ values, tags });

API

inject (static)

MetasManager.inject({ values, tags, autoCreateMetaTag, autoRemoveMetaTag });

Parameters

Object:

  • values (TMetaTags): object of values to inject - default: null
  • tags (TMetaTags): object of meta tags struct - default: MetasManager.DEFAULT_META_TAGS
  • autoCreateMetaTag (boolean): auto create meta tag in document head if doesn't exist - default: true
  • autoRemoveMetaTag (boolean): auto remove meta tag in document head if value is "" - default: true

Returns

(Void)