3.1.6 • Published 2 years ago

og-metadata v3.1.6

Weekly downloads
-
License
-
Repository
github
Last release
2 years ago

status

og-metadata

An npm package to access website metadata & link tags. Returns the title, description, favicon, preview image, keywords, theme color, etc. for a given website url.

Install

With npm:

npm install og-metadata

With yarn:

yarn add og-metadata

Example

Add og-metadata to a Nodejs project & access like

// example export as a Firebase Function
exports.getUrlMetadata = functions.https.onCall((data, context) => {
  const url = data.url; // eg. https://tylerj.me
  if (url) {
    // begin og-metadata code
    const MetaInspector = require("og-metadata");

    var client = new MetaInspector(url, { timeout: 5000 });
    return client.fetch().then(() => {
      // note: no error handling yet
      const data = {
        title: client.title,
        description: client.description,
        image: client.image,
        favicon: client.favicon,
        appleTouchIcon: client.appleTouchIcon,
        url: client.url,
        host: client.host,
        keywords: client.keywords,
        themeColor: client.themeColor,
        twitterCreator: client.twitterCreator,
      };
      return data;
    });
  }
});

Available data

KeyDescription
urlfull url of the page
schemescheme of the page (http, https)
hosthostname of the page (eg. tylerj.me)
rootUrlabsolute url of the page w/o subpages or queries
titletitle of the page
descriptiondescription of the page or the first long paragraph if no meta description is provided
authorpage author
keywordspage keywords, as an array
charsetcharset of the page
linksevery link found on the page, as an array
themeColortheme color of the page, if provided
imagesocial preview image of the page
faviconwebsite favicon image
appleTouchIconApple touch icon of the page, if provided
imagesevery image found on the page, as an array
feedsrss or atom links, as an array
ogTitleopengraph title
ogDescriptionopengraph description
ogTypeopengraph object type
ogUpdatedTimeopengraph updated time
ogLocaleopengraph locale language
ogImageAltopengraph image alt text
twitterCreatorTwitter creator, if provided

Options

OptionDescriptionDefault value
timeoutthe time in ms to wait for the url to respond20000ms
maxRedirectsthe number of redirects allowed5
strictSSLforce SSL (https instead of http)false
headersoptions headers for the request{ 'User-Agent' : 'MetaInspector/1.0' }
3.1.6

2 years ago

3.1.5

2 years ago

3.1.4

2 years ago

3.1.3

2 years ago

3.1.2

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.0.9

2 years ago

3.0.8

2 years ago

3.0.7

2 years ago

3.0.6

2 years ago

3.0.5

2 years ago

3.0.4

2 years ago

3.0.3

2 years ago

3.0.2

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago