1.0.3 • Published 11 months ago

uri-metadata v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

uri-metadata

uri-metadata is a TypeScript library for extracting metadata information, including Twitter and Open Graph properties, from any HTTP/HTTPS URL. It is specifically designed to be useful in development of Chrome extensions.

Highlights

Installation

npm install uri-metadata --save

Usage

Fetch metadata using the provided example below, which returns a Promise:

import metadata from "uri-metadata";

try {
  const response = await metadata.get("https://awwwards.com");
  console.log("Metadata: ", response);
} catch (err) {
  console.log("An error occurred: ", err);
}

Alternatively, you can pass a callback function:

import metadata from "uri-metadata";

metadata.get("https://awwwards.com", (data, err) => {
  console.log(err ? err : data);
});

The response is an object containing the URL metadata grouped by type:

{
  meta: {
    'theme-color': '#3ea094',
    referrer: 'origin-when-cross-origin',
    keywords: 'Website Awards, Web Design Inspiration, Webdesign Trends',
    ...
  },
  og: {
    type: 'website',
    site_name: 'Awwwards',
    ...
  },
  twitter: {
    ...
  }
}

Options

You can pass true or false as a third argument to group or ungroup metatags (defaults to true). For example:

response = await metadata.get("https://www.awwwards.com", false);

This returns:

{
  'og:type': 'website',
  'theme-color': '#3ea094',
  'og:site_name': 'Awwwards',
  referrer: 'origin-when-cross-origin',
  keywords: 'Website Awards, Web Design Inspiration, Webdesign Trends',
  ...
}

Contributing

  1. Fork the repository and create your feature branch: git checkout -b my-update
  2. Commit your changes: git commit -am 'Updated some parts'
  3. Push to the branch: git push origin my-update
  4. Submit a pull request
1.0.2

12 months ago

1.0.3

11 months ago

1.0.1

2 years ago

1.2.3

2 years ago

1.2.4

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago