get-metadata
A utility function for querying and normalizing DOM metadata content. Useful for passing initial JSON values to frontend apps, without multiple server requests.
Installation
npm install get-metadata
Usage
var getMetadata = // => {foo: 'bar', baz: [1337, true, null]} // => '@lukamaljic' // => 'https://github.com/malj/get-metadata' // => null // => undefined
API
getMetadata(name, [options])
Query the DOM for a meta element with the attribute "name" value equal to the name
param and return its "content" attribute value. Options:
- key (default:
'name'
): Queries a meta tag by this attribute key - warn (default:
false
): Displays a warning in the console if no meta element is found