glancify
Version:
Get title, description and image from a URL for link preview purposes
62 lines (43 loc) • 1.2 kB
Markdown
# Glancify
🔍 **Glancify** is a lightweight TypeScript library that generates a link preview from any public URL by extracting the page's title, description, and Open Graph image.
## ✨ Features
- Automatically extracts:
- `<title>` tag
- Meta `description` tag
- Open Graph meta tags: `og:title`, `og:description`, `og:image`
- Returns a clean and simple JSON object
- Written entirely in TypeScript
- Designed for server-side usage (Node.js)
## 📦 Installation
```bash
npm install glancify
````
## 🚀 Usage
```ts
import { glancify } from 'glancify';
(async () => {
const preview = await glancify('https://example.com');
console.log(preview);
})();
```
Example output:
```json
{
"title": "Example Page Title",
"description": "This is the meta description of the page.",
"image": "https://example.com/og-image.jpg"
}
```
## ⚠️ Notes
* Works only with publicly accessible HTTP/HTTPS URLs
* Ideal for backends, social previews, content scrapers
* Assumes HTML is UTF-8 encoded
## 🛠️ Future Enhancements
* Support for non-UTF-8 charsets
* Add timeout and retry logic
* Use a real HTML parser for improved robustness (e.g. `cheerio`)