Package Exports
- uri-metadata
- uri-metadata/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (uri-metadata) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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 --saveUsage
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
- Fork the repository and create your feature branch:
git checkout -b my-update - Commit your changes:
git commit -am 'Updated some parts' - Push to the branch:
git push origin my-update - Submit a pull request