[dyad] Added social media tag analysis - wrote 5 file(s)
This commit is contained in:
@@ -58,6 +58,28 @@ export async function extractMetaData(url: string, keyword?: string) {
|
||||
const canonical = $('link[rel="canonical"]').attr("href") || null;
|
||||
const robots = $('meta[name="robots"]').attr("content") || null;
|
||||
|
||||
// Social Tags
|
||||
const openGraph = {
|
||||
title: $('meta[property="og:title"]').attr("content") || title,
|
||||
description:
|
||||
$('meta[property="og:description"]').attr("content") || description,
|
||||
image: $('meta[property="og:image"]').attr("content") || image,
|
||||
url: $('meta[property="og:url"]').attr("content") || null,
|
||||
siteName: $('meta[property="og:site_name"]').attr("content") || null,
|
||||
type: $('meta[property="og:type"]').attr("content") || null,
|
||||
};
|
||||
|
||||
const twitter = {
|
||||
card: $('meta[name="twitter:card"]').attr("content") || null,
|
||||
title: $('meta[name="twitter:title"]').attr("content") || openGraph.title,
|
||||
description:
|
||||
$('meta[name="twitter:description"]').attr("content") ||
|
||||
openGraph.description,
|
||||
image: $('meta[name="twitter:image"]').attr("content") || openGraph.image,
|
||||
site: $('meta[name="twitter:site"]').attr("content") || null,
|
||||
creator: $('meta[name="twitter:creator"]').attr("content") || null,
|
||||
};
|
||||
|
||||
const faqData: FaqItem[] = [];
|
||||
const schemaData: any[] = [];
|
||||
$('script[type="application/ld+json"]').each((i, el) => {
|
||||
@@ -177,6 +199,8 @@ export async function extractMetaData(url: string, keyword?: string) {
|
||||
image,
|
||||
canonical,
|
||||
robots,
|
||||
openGraph,
|
||||
twitter,
|
||||
faq: faqData.length > 0 ? faqData : null,
|
||||
schema: schemaData.length > 0 ? schemaData : null,
|
||||
headlines: headlines.length > 0 ? headlines : null,
|
||||
|
||||
Reference in New Issue
Block a user