0.0.3 • Published 9 years ago
@joegesualdo/get-meta-information-from-html v0.0.3
@joegesualdo/get-meta-information-from-html 
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 testAPI
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 buildLicense
MIT © Joe Gesualdo