UNPKG

pyseoa-ts

Version:

SEO analysis tools for the web, ported from pyseoa (Python) to TypeScript

23 lines (22 loc) 678 B
import * as cheerio from 'cheerio'; export function analyzeRobots(html) { const $ = cheerio.load(html); const content = $('meta[name="robots"]').attr("content"); if (content === undefined) return { score: 0, message: "Missing robots meta tag.", }; const value = content.trim().toLowerCase(); if (value.includes("noindex") || value.includes("nofollow")) return { score: 1, message: "Robots meta tag contains noindex or nofollow.", content: value, }; return { score: 3, message: "Robots meta tag allows indexing.", content: value, }; }