Giter Site home page Giter Site logo

link-enricher's Introduction

link-enricher

Tests

Fetch oEmbed, Opeh Graph, etc info for links

Install

npm install link-enricher

Use

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?: FileResult
    • video?: FileResult
    • attachment?: FileResult — if Content-Dispotition header responds
    • webpage?: WebpageResult
    • oembed?: OEmbedResult
  • FileResult
    • name?: string
    • size?: number — size in bytes
    • type?: string — mime type
    • ext?: string — extension in format jpeg
  • WebpageResult:
    • type?: string
    • url?: string
    • name?: string
    • title?: string
    • description?: string
    • icons: WebpageIcon[]
    • images: WebpageMedia[]
    • videos: WebpageMedia[]
    • audios: WebpageMedia[]
  • WebpageIcon:
    • rel: 'icon'|'apple-touch-icon'|'manifest'
    • url: string
    • width?: number
    • height?: number
    • type?: string
  • WebpageMedia:
    • url: string
    • type?: string
    • width?: number
    • height?: number
  • OEmbedResult:
    • type: string
    • title?: string
    • thumbnail?: WebpageMedia
    • author?: OEmbedAuthor
    • provider?: OEmbedAuthor & { id: string }
    • width?: number
    • height?: number
    • href?: string
    • html?: string
  • OEmbedAuthor:
    • name: string
    • url?: string

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.