1.1.1 • Published 1 year ago
link-enricher v1.1.1
link-enricher
Fetch oEmbed, Opeh Graph, etc info for links
Install
npm install link-enricherUse
enrichLink(url: string, userAgent?: string): Promise<LinkEnricherResult>import { enrichLink } from 'link-enricher';
enrichLink('https://journal.teletype.in/donations').then(result => {
console.log(result);
/*
{
"webpage": {
"type": "article",
"url": "https://journal.teletype.in//donations",
"name": "Teletype",
"title": "Some title",
"description": "Some description",
"icons": [
{
"rel": "icon",
"url": "https://journal.teletype.in/favicon.ico",
"type": "image/x-icon"
},
{
"rel": "icon",
"url": "https://teletype.in/static/images/favicon.aa44a25d7abf771753ddc4882d74b1d3.svg",
"type": "image/svg+xml"
},
{
"rel": "apple-touch-icon",
"url": "https://teletype.in/static/images/apple-touch-icon.bff1896956c63f4f4e03a61cd7730434.png",
"type": "image/png"
}
],
"images": [
{
"url": "https://img1.teletype.in/files/42/a2/42a296b5-2e20-47c9-b55f-0925c6c5ca38.png",
"type": "image/png"
},
{
"url": "https://img1.teletype.in/files/42/a2/42a296b5-2e20-47c9-b55f-0925c6c5ca38.png",
"type": "image/png",
"width": 1200,
"height": 630
}
],
"videos": [],
"audios": []
}
}
*/
})Types
- LinkEnricherResult:
image?: FileResultvideo?: FileResultattachment?: FileResult— ifContent-Dispotitionheader respondswebpage?: WebpageResultoembed?: OEmbedResult
- FileResult
name?: stringsize?: number— size in bytestype?: string— mime typeext?: string— extension in formatjpeg
- WebpageResult:
type?: stringurl?: stringname?: stringtitle?: stringdescription?: stringicons: WebpageIcon[]images: WebpageMedia[]videos: WebpageMedia[]audios: WebpageMedia[]
- WebpageIcon:
rel: 'icon'|'apple-touch-icon'|'manifest'url: stringwidth?: numberheight?: numbertype?: string
- WebpageMedia:
url: stringtype?: stringwidth?: numberheight?: number
- OEmbedResult:
type: stringtitle?: stringthumbnail?: WebpageMediaauthor?: OEmbedAuthorprovider?: OEmbedAuthor & { id: string }width?: numberheight?: numberhref?: stringhtml?: string
- OEmbedAuthor:
name: stringurl?: string