Skip to content

Instantly share code, notes, and snippets.

@westonruter
Created August 27, 2014 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westonruter/70170ad3d24bf017e73e to your computer and use it in GitHub Desktop.
Save westonruter/70170ad3d24bf017e73e to your computer and use it in GitHub Desktop.
( function () {
var els = [].slice.call( document.querySelectorAll( 'title, meta[content][name], meta[content][property]' ) );
var meta = {};
els.forEach( function ( el ) {
if ( el.nodeName.toLowerCase() === 'title' ) {
meta.title = el.textContent;
} else {
meta[ el.getAttribute( 'property' ) || el.getAttribute( 'name' ) ] = el.getAttribute( 'content' );
}
} );
return meta;
} () );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment