mirror of
https://github.com/jakejarvis/hoot.git
synced 2025-10-18 20:14:25 -04:00
Add SEO metadata fields for keywords, author, and generator
This commit is contained in:
@@ -76,8 +76,11 @@ export function SeoSection({
|
||||
const metaTagValues: { label: string; value?: string | null }[] = [
|
||||
{ label: "Title", value: data?.preview?.title },
|
||||
{ label: "Description", value: data?.preview?.description },
|
||||
{ label: "Keywords", value: data?.meta?.general.keywords },
|
||||
{ label: "Author", value: data?.meta?.general.author },
|
||||
{ label: "Canonical", value: data?.preview?.canonicalUrl },
|
||||
{ label: "Image", value: data?.preview?.image },
|
||||
{ label: "Generator", value: data?.meta?.general.generator },
|
||||
{ label: "Robots", value: data?.meta?.general.robots },
|
||||
];
|
||||
const metaTagCount = metaTagValues.filter((t) => t.value != null).length;
|
||||
|
@@ -46,7 +46,10 @@ export const TwitterMetaSchema = z.object({
|
||||
export const GeneralMetaSchema = z.object({
|
||||
title: z.string().optional(),
|
||||
description: z.string().optional(),
|
||||
keywords: z.string().optional(),
|
||||
author: z.string().optional(),
|
||||
canonical: z.string().url().optional(),
|
||||
generator: z.string().optional(),
|
||||
robots: z.string().optional(),
|
||||
});
|
||||
|
||||
|
@@ -53,6 +53,9 @@ export function parseHtmlMeta(html: string, finalUrl: string): SeoMeta {
|
||||
);
|
||||
const canonicalHref = $('link[rel="canonical"]').attr("href") ?? "";
|
||||
const robotsMeta = $('meta[name="robots"]').attr("content") ?? "";
|
||||
const generatorMeta = $('meta[name="generator"]').attr("content") ?? "";
|
||||
const authorMeta = $('meta[name="author"]').attr("content") ?? "";
|
||||
const keywordsMeta = $('meta[name="keywords"]').attr("content") ?? "";
|
||||
|
||||
const og: OpenGraphMeta = {
|
||||
title: pickMetaAttr($, "property", "og:title"),
|
||||
@@ -81,7 +84,10 @@ export function parseHtmlMeta(html: string, finalUrl: string): SeoMeta {
|
||||
const general: GeneralMeta = {
|
||||
title: titleTag || undefined,
|
||||
description: descriptionTag || undefined,
|
||||
keywords: sanitizeText(keywordsMeta) || undefined,
|
||||
author: sanitizeText(authorMeta) || undefined,
|
||||
canonical: sanitizeText(canonicalHref) || undefined,
|
||||
generator: sanitizeText(generatorMeta) || undefined,
|
||||
robots: sanitizeText(robotsMeta) || undefined,
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user