@joegesualdo/get-meta-information-from-html
v0.0.3
Published
Get <meta> tags information from HTML.
Downloads
2
Readme
@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 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