import { SearchCheckIcon } from 'lucide-react'; import { classNames } from '../../lib/utils'; import { KEYWORD_TESTS, scoreTone, type Analysis } from '../analysis/analyzer'; import { isToFix } from './result-tone'; import { TONE_CLASSES, TONE_LABELS } from './ScoreBadge'; /** * What the publish check says about SEO, as Rank Math and Yoast say it * there: the score, the focus keyword, how many tests fail, and the way to * the SEO panel. * * @param props - Component props. * @param props.analysis - The analysis of the post as edited. * @param props.keyword - Its first focus keyword. * @param props.onOpen - Opens the SEO sidebar. * @return The summary. */ export const PrePublishSummary = ({ analysis, keyword, onOpen, }: { analysis: Analysis; keyword: string; onOpen: () => void; }): JSX.Element => { const counted = analysis.needsKeyword ? analysis.results.filter(result => !KEYWORD_TESTS.includes(result.id)) : analysis.results; const weighted = counted.filter(result => result.max > 0); const passed = weighted.filter(result => result.passed).length; const toFix = weighted.filter(isToFix).length; const tone = analysis.needsKeyword ? null : scoreTone(analysis.score); return (
{tone ? `${TONE_LABELS[tone]} · ${analysis.score}/100` : 'No score yet: add a focus keyword'}
{keyword && (Focus keyword: {keyword}
)}{passed} of {weighted.length} tests passed {toFix > 0 ? ` · ${toFix} to fix` : ''}