metash
v0.1.1
Published
A lightweight and extensible HTML metadata extractor.
Readme
Metash
A lightweight and extensible HTML metadata extractor with default Open Graph, Twitter Cards, and standard <head> tag parsers.
Examples
import parseMeta from "metash";
const res = await fetch("https://example.com");
const meta = await parseMeta(res);
console.log(meta);Including standard-specific data
const meta = await parseMeta(res, ["og", "tw"]);
console.log(meta.og);
console.log(meta.tw);Custom parsers
const meta = await parseMeta(res, ["custom"], {
custom(root, baseUrl) {
const author = root.querySelector('meta[name="author"]')?.getAttribute("content");
return { title: `Post from ${author}`, data: { author }, priority: 1 };
},
});
console.log(meta.custom.author);