diff options
| author | Kush Thaker <[email protected]> | 2024-07-31 10:56:40 +0530 |
|---|---|---|
| committer | Kush Thaker <[email protected]> | 2024-07-31 10:56:40 +0530 |
| commit | 6e1d53e28a056e429c54e1e6af45eaa7939daa41 (patch) | |
| tree | 21dfd3c64742d9e9405e68b1695acbb95f5fdde2 /apps/web/lib | |
| parent | fix ids not present in storecontent (diff) | |
| download | supermemory-6e1d53e28a056e429c54e1e6af45eaa7939daa41.tar.xz supermemory-6e1d53e28a056e429c54e1e6af45eaa7939daa41.zip | |
queues so far
Co-authored-by: Dhravya Shah <[email protected]>
Diffstat (limited to 'apps/web/lib')
| -rw-r--r-- | apps/web/lib/get-metadata.ts | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/apps/web/lib/get-metadata.ts b/apps/web/lib/get-metadata.ts deleted file mode 100644 index c81397ff..00000000 --- a/apps/web/lib/get-metadata.ts +++ /dev/null @@ -1,40 +0,0 @@ -"use server"; -import * as cheerio from "cheerio"; - -// TODO: THIS SHOULD PROBABLY ALSO FETCH THE OG-IMAGE -export async function getMetaData(url: string) { - const response = await fetch(url); - const html = await response.text(); - - const $ = cheerio.load(html); - - // Extract the base URL - const baseUrl = url; - - // Extract title - const title = $("title").text().trim(); - - const description = $("meta[name=description]").attr("content") ?? ""; - - const _favicon = - $("link[rel=icon]").attr("href") ?? "https://supermemory.dhr.wtf/web.svg"; - - let favicon = - _favicon.trim().length > 0 - ? _favicon.trim() - : "https://supermemory.dhr.wtf/web.svg"; - if (favicon.startsWith("/")) { - favicon = baseUrl + favicon; - } else if (favicon.startsWith("./")) { - favicon = baseUrl + favicon.slice(1); - } - - // Prepare the metadata object - const metadata = { - title, - description, - image: favicon, - baseUrl, - }; - return metadata; -} |