@joegesualdo/get-meta-information-from-html

0.0.3 • Public • Published

@joegesualdo/get-meta-information-from-html Build Status

Get <meta> tags information from HTML.

Install

$ npm install --save @joegesualdo/get-meta-information-from-html 

Usage

import getMetaInformationFromHTML from '@joegesualdo/get-meta-information-from-html'

let html = `
  <head>
    <meta itemprop="description" content="This is a description">
    <meta name="title" content="This is a Title">
  </head>
`

getMetaInformationFromHTML(html)
.then(result => {
  console.log(result)
  //=>[
  //    {
  //      typeKey: 'itemprop',
  //      typeValue: 'description',
  //      value: 'This is a description' 
  //    },
  //    {
  //      typeKey: 'name',
  //      typeValue: 'Title',
  //      value: 'This is a title'
  //    }
  // ]
})

NOTE: Only looks for tags in the child nodes of the html provided. (Ie. <head><meta><head>)

Test

$ npm test

API

getMetaInformationFromHTML(html)

Get all the information from tags within the html provided

Name Type Description
html String The HTML you want to evaluate the tags from

Returns: Object, containing these keys: typeKey, typeValue, and value

import getMetaInformationFromHTML from '@joegesualdo/get-meta-information-from-html';

let html = `
  <head>
    <meta itemprop="description" content="This is a description">
    <meta name="title" content="This is a Title">
  </head>
`
getMetaInformationFromHTML(html)
.then(result => {
  console.log(result)
  //=>[
  //    {
  //      typeKey: 'itemprop',
  //      typeValue: 'description',
  //      value: 'This is a description' 
  //    },
  //    {
  //      typeKey: 'name',
  //      typeValue: 'Title',
  //      value: 'This is a title'
  //    }
  // ]
})

Build

$ npm run build

License

MIT © Joe Gesualdo

Readme

Keywords

Package Sidebar

Install

npm i @joegesualdo/get-meta-information-from-html

Weekly Downloads

6

Version

0.0.3

License

MIT

Last publish

Collaborators

  • joegesualdo