Coder Social home page Coder Social logo

html-meta-tags's Introduction

html-meta-tags Build Status

Generate HTML meta tags from JSON data.

Install

npm install html-meta-tags -g

Usage

CLI

You can either pipe data from the standard input or specify a file path for the program.

$ html-meta-tags

Usage: html-meta-tags <file> [options]

Example:
  cat data.json | html-meta-tags

Options:
  -v --version          Display current program version
  -h --help             Display help and usage details
     --no-charset       Do not specify UTF-8 as document charset
     --no-og            Do not generate Open Graph meta tags
     --no-twitter       Do not generate Twitter meta tags

$ echo '
{
  "title": "My Website",
  "url": "https://mywebsite.com",
  "keywords": ["blockchain", "infosec", "crypto"],
  "description": "This is my personal website"
}' | html-meta-tags
<meta charset="utf-8">
<meta name="title" content="My Website">
<meta name="url" content="https://mywebsite.com">
<meta name="keywords" content="blockchain, infosec, crypto">
<meta name="description" content="This is my personal website">
<meta name="twitter:description" content="This is my personal website">
<meta name="twitter:title" content="My Website">
<meta property="og:description" content="This is my personal website">
<meta property="og:title" content="My Website">

Node.js

var htmlMetaTags = require('html-meta-tags')
var data = require('./data.json')

console.log(htmlMetaTags(data))

API

htmlMetaTags(data, [options])

Returns an HTML string containing a representation of all meta tags from data.

data

Type: Object

Meta tags in object notation format.

  • You can use arrays for comma-separated such as keywords or viewport.
  • If a specific value for a prefixed key is specified it will take precedence over the default.
  • Prefixed keys should have their own entry, og:title for example, should be represented as:
{
  og: {
    title: 'value'
  }
}

options

Type: Object

shouldIgnoreCharset

Type: boolean
Default: false

Whether or not it should render UTF-8 charset meta tag.

shouldIgnoreTwitter

Type: boolean
Default: false

Whether or not it should render Twitter specific meta tags.

shouldIgnoreOpenGraph

Type: boolean
Default: false

Whether or not it should render Open Graph specific meta tags.

License

MIT ยฉ Rafael Rinaldi


Buy me a โ˜•

html-meta-tags's People

Contributors

dependabot-preview[bot] avatar depfu[bot] avatar rafaelrinaldi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

html-meta-tags's Issues

Cross-site-scripting vulnerability

This module doesn't seem to escape dangerous HTML characters. It is vulnerable to CSS.

{"name": "\"/><script>alert(\"hacked\");</script><meta hoge=\""}

Should not output image

Image is valid both for OG and Twitter, but there's no such thing as a "native" image meta tag. Remove it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.