2026-02-27 14:09:33 -05:00

26 lines
785 B
TypeScript

import type { KeywordIntent, MonthlySearch } from "@/types/keywords";
export type EnrichedKeyword = {
keyword: string;
searchVolume: number | null;
trend: MonthlySearch[];
cpc: number | null;
competition: number | null;
keywordDifficulty: number | null;
intent: KeywordIntent;
};
export function normalizeKeyword(input: string): string {
return input.trim().toLowerCase();
}
export function normalizeIntent(raw: unknown): KeywordIntent {
if (typeof raw !== "string") return "unknown";
const value = raw.toLowerCase();
if (value.includes("inform")) return "informational";
if (value.includes("commerc")) return "commercial";
if (value.includes("transact")) return "transactional";
if (value.includes("navig")) return "navigational";
return "unknown";
}