Skip to content

bobheadxi/metadata

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

metadata npm (scoped)

Pull metadata from a webpage through a crude heuristic that leverages regular HTML metadata, OpenGraph, JSON+LD data, and more.

npm i -s @bobheadxi/metadata
import { parseMeta } from '@bobheadxi/metadata';

export async function getMeta() {
    const resp = await fetch('https://bobheadxi.dev');
    const doc = new DOMParser().parseFromString(await resp.text(), 'text/html');
    return parseMeta(doc);
}

about

@bobheadxi/metadata is a minimal-dependency library for pulling metadata from a given webpage. What seems to be the de facto standard for doing so, metascraper, is so elaborate that there appears to be no intention for supporting browser environments, and much to my suprise I was unable to find a semi-robust library that would work in browsers. So I hacked this together.