[dyad] Added more fields to meta analysis - wrote 2 file(s)
This commit is contained in:
@@ -55,6 +55,9 @@ export async function extractMetaData(url: string, keyword?: string) {
|
|||||||
$('meta[name="description"]').attr("content") ||
|
$('meta[name="description"]').attr("content") ||
|
||||||
"No description found";
|
"No description found";
|
||||||
const image = $('meta[property="og:image"]').attr("content") || null;
|
const image = $('meta[property="og:image"]').attr("content") || null;
|
||||||
|
const canonical = $('link[rel="canonical"]').attr("href") || null;
|
||||||
|
const keywords = $('meta[name="keywords"]').attr("content") || null;
|
||||||
|
const robots = $('meta[name="robots"]').attr("content") || null;
|
||||||
|
|
||||||
const faqData: FaqItem[] = [];
|
const faqData: FaqItem[] = [];
|
||||||
const schemaData: any[] = [];
|
const schemaData: any[] = [];
|
||||||
@@ -173,6 +176,9 @@ export async function extractMetaData(url: string, keyword?: string) {
|
|||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
image,
|
image,
|
||||||
|
canonical,
|
||||||
|
keywords,
|
||||||
|
robots,
|
||||||
faq: faqData.length > 0 ? faqData : null,
|
faq: faqData.length > 0 ? faqData : null,
|
||||||
schema: schemaData.length > 0 ? schemaData : null,
|
schema: schemaData.length > 0 ? schemaData : null,
|
||||||
headlines: headlines.length > 0 ? headlines : null,
|
headlines: headlines.length > 0 ? headlines : null,
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ import {
|
|||||||
X,
|
X,
|
||||||
ImageOff,
|
ImageOff,
|
||||||
Search,
|
Search,
|
||||||
|
ShieldCheck,
|
||||||
|
ShieldX,
|
||||||
|
Link as LinkIcon,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import {
|
import {
|
||||||
extractMetaData,
|
extractMetaData,
|
||||||
@@ -31,6 +34,7 @@ import { TabIndicator } from "./tab-indicator";
|
|||||||
import { getLengthIndicatorColor, type IndicatorColor } from "@/lib/analysis";
|
import { getLengthIndicatorColor, type IndicatorColor } from "@/lib/analysis";
|
||||||
import { KeywordHighlighter } from "./keyword-highlighter";
|
import { KeywordHighlighter } from "./keyword-highlighter";
|
||||||
import { SchemaDisplay } from "./schema-display";
|
import { SchemaDisplay } from "./schema-display";
|
||||||
|
import { Badge } from "./ui/badge";
|
||||||
|
|
||||||
interface MetaData {
|
interface MetaData {
|
||||||
title: string;
|
title: string;
|
||||||
@@ -42,6 +46,9 @@ interface MetaData {
|
|||||||
keyword?: string | null;
|
keyword?: string | null;
|
||||||
keywordCount?: number | null;
|
keywordCount?: number | null;
|
||||||
images?: ImageAltData[] | null;
|
images?: ImageAltData[] | null;
|
||||||
|
canonical?: string | null;
|
||||||
|
keywords?: string | null;
|
||||||
|
robots?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function MetaForm() {
|
export function MetaForm() {
|
||||||
@@ -442,6 +449,105 @@ export function MetaForm() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
<div>
|
||||||
|
<h3 className="font-semibold text-card-foreground">
|
||||||
|
Indexability
|
||||||
|
</h3>
|
||||||
|
<p className="text-sm text-muted-foreground mt-1 mb-2">
|
||||||
|
Indicates if search engines are allowed to index this
|
||||||
|
page.
|
||||||
|
</p>
|
||||||
|
{(() => {
|
||||||
|
const isIndexable =
|
||||||
|
!metaData.robots ||
|
||||||
|
!metaData.robots.toLowerCase().includes("noindex");
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={`flex items-start gap-3 p-3 rounded-md ${
|
||||||
|
isIndexable
|
||||||
|
? "bg-green-500/10 border-green-500/20"
|
||||||
|
: "bg-red-500/10 border-red-500/20"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{isIndexable ? (
|
||||||
|
<ShieldCheck className="h-5 w-5 text-green-500 mt-0.5 flex-shrink-0" />
|
||||||
|
) : (
|
||||||
|
<ShieldX className="h-5 w-5 text-red-500 mt-0.5 flex-shrink-0" />
|
||||||
|
)}
|
||||||
|
<div>
|
||||||
|
<p
|
||||||
|
className={`font-semibold ${
|
||||||
|
isIndexable
|
||||||
|
? "text-green-700 dark:text-green-400"
|
||||||
|
: "text-red-700 dark:text-red-400"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{isIndexable
|
||||||
|
? "Page is indexable"
|
||||||
|
: "Page is set to 'noindex'"}
|
||||||
|
</p>
|
||||||
|
<p className="text-sm text-muted-foreground">
|
||||||
|
{metaData.robots
|
||||||
|
? `Robots tag: "${metaData.robots}"`
|
||||||
|
: "No robots meta tag found."}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})()}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<h3 className="font-semibold text-card-foreground">
|
||||||
|
Canonical URL
|
||||||
|
</h3>
|
||||||
|
<CopyButton
|
||||||
|
textToCopy={metaData.canonical || "Not found"}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<p className="text-sm text-muted-foreground mt-1 mb-2">
|
||||||
|
The preferred URL for this page, to avoid duplicate
|
||||||
|
content issues.
|
||||||
|
</p>
|
||||||
|
<p className="text-muted-foreground bg-muted p-3 rounded-md min-h-[40px] break-all flex items-center gap-2">
|
||||||
|
{metaData.canonical ? (
|
||||||
|
<>
|
||||||
|
<LinkIcon className="h-4 w-4 flex-shrink-0" />
|
||||||
|
<span className="truncate">
|
||||||
|
{metaData.canonical}
|
||||||
|
</span>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
"Not found"
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3 className="font-semibold text-card-foreground">
|
||||||
|
Meta Keywords
|
||||||
|
</h3>
|
||||||
|
<p className="text-sm text-muted-foreground mt-1 mb-2">
|
||||||
|
Keywords associated with the page. Note: Most search
|
||||||
|
engines no longer use this tag for ranking.
|
||||||
|
</p>
|
||||||
|
<div className="text-muted-foreground bg-muted p-3 rounded-md min-h-[40px]">
|
||||||
|
{metaData.keywords ? (
|
||||||
|
<div className="flex flex-wrap gap-2">
|
||||||
|
{metaData.keywords
|
||||||
|
.split(",")
|
||||||
|
.map((k) => k.trim())
|
||||||
|
.filter(Boolean)
|
||||||
|
.map((k, i) => (
|
||||||
|
<Badge key={i} variant="secondary">
|
||||||
|
{k}
|
||||||
|
</Badge>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
"Not found"
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|||||||
Reference in New Issue
Block a user