aeorank 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -29,6 +29,7 @@ __export(index_exports, {
29
29
  buildScorecard: () => buildScorecard,
30
30
  calculateOverallScore: () => calculateOverallScore,
31
31
  classifyRendering: () => classifyRendering,
32
+ compare: () => compare,
32
33
  detectParkedDomain: () => detectParkedDomain,
33
34
  extractContentPagesFromSitemap: () => extractContentPagesFromSitemap,
34
35
  extractNavLinks: () => extractNavLinks,
@@ -36,6 +37,8 @@ __export(index_exports, {
36
37
  fetchMultiPageData: () => fetchMultiPageData,
37
38
  fetchWithHeadless: () => fetchWithHeadless,
38
39
  generateBottomLine: () => generateBottomLine,
40
+ generateComparisonHtmlReport: () => generateComparisonHtmlReport,
41
+ generateHtmlReport: () => generateHtmlReport,
39
42
  generateOpportunities: () => generateOpportunities,
40
43
  generatePitchNumbers: () => generatePitchNumbers,
41
44
  generateVerdict: () => generateVerdict,
@@ -2556,6 +2559,329 @@ async function audit(domain, options) {
2556
2559
  ...renderedWithHeadless && { renderedWithHeadless: true }
2557
2560
  };
2558
2561
  }
2562
+
2563
+ // src/html-report.ts
2564
+ function scoreColor(score) {
2565
+ if (score <= 40) return "#F44336";
2566
+ if (score <= 55) return "#FF9800";
2567
+ if (score <= 70) return "#FFC107";
2568
+ if (score <= 85) return "#4CAF50";
2569
+ return "#2E7D32";
2570
+ }
2571
+ function criterionColor(score) {
2572
+ return scoreColor(score * 10);
2573
+ }
2574
+ function escapeHtml(str) {
2575
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
2576
+ }
2577
+ function scoreCircleSvg(score, size = 160) {
2578
+ const radius = (size - 16) / 2;
2579
+ const circumference = 2 * Math.PI * radius;
2580
+ const progress = score / 100 * circumference;
2581
+ const color = scoreColor(score);
2582
+ return `<svg width="${size}" height="${size}" viewBox="0 0 ${size} ${size}">
2583
+ <circle cx="${size / 2}" cy="${size / 2}" r="${radius}" fill="none" stroke="#e0e0e0" stroke-width="10"/>
2584
+ <circle cx="${size / 2}" cy="${size / 2}" r="${radius}" fill="none" stroke="${color}" stroke-width="10"
2585
+ stroke-dasharray="${circumference}" stroke-dashoffset="${circumference - progress}"
2586
+ stroke-linecap="round" transform="rotate(-90 ${size / 2} ${size / 2})"/>
2587
+ <text x="${size / 2}" y="${size / 2 + 2}" text-anchor="middle" dominant-baseline="middle"
2588
+ font-size="42" font-weight="700" fill="${color}">${score}</text>
2589
+ <text x="${size / 2}" y="${size / 2 + 24}" text-anchor="middle" dominant-baseline="middle"
2590
+ font-size="13" fill="#666">/100</text>
2591
+ </svg>`;
2592
+ }
2593
+ var CSS = `
2594
+ * { margin: 0; padding: 0; box-sizing: border-box; }
2595
+ body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: #1a1a1a; background: #f8f9fa; line-height: 1.6; }
2596
+ .container { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }
2597
+ .header { text-align: center; margin-bottom: 40px; }
2598
+ .header h1 { font-size: 28px; font-weight: 700; margin-bottom: 4px; }
2599
+ .header .date { color: #666; font-size: 14px; }
2600
+ .score-section { display: flex; justify-content: center; margin: 24px 0 32px; }
2601
+ .verdict { background: #fff; border: 1px solid #e0e0e0; border-radius: 8px; padding: 20px 24px; margin-bottom: 32px; font-size: 15px; color: #333; }
2602
+ .section-title { font-size: 20px; font-weight: 700; margin-bottom: 16px; color: #1a1a1a; }
2603
+ .scorecard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-bottom: 32px; }
2604
+ .criterion-card { background: #fff; border: 1px solid #e0e0e0; border-radius: 8px; padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
2605
+ .criterion-bar { width: 80px; height: 8px; background: #e0e0e0; border-radius: 4px; flex-shrink: 0; overflow: hidden; }
2606
+ .criterion-bar-fill { height: 100%; border-radius: 4px; }
2607
+ .criterion-score { font-size: 14px; font-weight: 700; min-width: 32px; text-align: center; }
2608
+ .criterion-name { font-size: 13px; flex: 1; }
2609
+ .criterion-status { font-size: 11px; color: #666; background: #f0f0f0; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
2610
+ table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e0e0e0; border-radius: 8px; overflow: hidden; margin-bottom: 32px; }
2611
+ th { background: #f5f5f5; text-align: left; padding: 10px 14px; font-size: 13px; font-weight: 600; color: #555; border-bottom: 1px solid #e0e0e0; }
2612
+ td { padding: 10px 14px; font-size: 13px; border-bottom: 1px solid #f0f0f0; }
2613
+ .impact-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; color: #fff; }
2614
+ .impact-critical { background: #F44336; }
2615
+ .impact-high { background: #FF5722; }
2616
+ .impact-quick-win { background: #4CAF50; }
2617
+ .impact-core-aeo { background: #2196F3; }
2618
+ .impact-medium { background: #FF9800; }
2619
+ .impact-low { background: #9E9E9E; }
2620
+ .impact-big-opportunity { background: #9C27B0; }
2621
+ .impact-measurement { background: #607D8B; }
2622
+ .bottom-line { background: #fff; border: 1px solid #e0e0e0; border-radius: 8px; padding: 20px 24px; margin-bottom: 32px; font-size: 15px; }
2623
+ .footer { text-align: center; color: #999; font-size: 12px; padding: 24px 0; border-top: 1px solid #e0e0e0; margin-top: 24px; }
2624
+ .compare-header { display: flex; justify-content: center; align-items: center; gap: 48px; margin-bottom: 32px; }
2625
+ .compare-site { text-align: center; }
2626
+ .compare-site h2 { font-size: 20px; margin-bottom: 8px; }
2627
+ .compare-vs { font-size: 24px; font-weight: 700; color: #999; }
2628
+ .delta-positive { color: #4CAF50; font-weight: 600; }
2629
+ .delta-negative { color: #F44336; font-weight: 600; }
2630
+ .delta-zero { color: #999; }
2631
+ .summary-box { background: #fff; border: 1px solid #e0e0e0; border-radius: 8px; padding: 16px 20px; margin-bottom: 24px; display: flex; gap: 24px; justify-content: center; flex-wrap: wrap; }
2632
+ .summary-stat { text-align: center; }
2633
+ .summary-stat .num { font-size: 28px; font-weight: 700; }
2634
+ .summary-stat .label { font-size: 12px; color: #666; }
2635
+ @media print {
2636
+ body { background: #fff; }
2637
+ .container { padding: 0; }
2638
+ .criterion-card, .verdict, .bottom-line, table { break-inside: avoid; }
2639
+ }
2640
+ @media (max-width: 640px) {
2641
+ .scorecard-grid { grid-template-columns: 1fr; }
2642
+ .compare-header { flex-direction: column; gap: 16px; }
2643
+ }
2644
+ `;
2645
+ function impactClass(impact) {
2646
+ const key = impact.toLowerCase().replace(/\s+/g, "-");
2647
+ return `impact-${key}`;
2648
+ }
2649
+ function generateHtmlReport(result) {
2650
+ const domain = escapeHtml(result.site);
2651
+ const date = escapeHtml(result.auditDate);
2652
+ const scorecardCards = result.scorecard.map((item) => {
2653
+ const color = criterionColor(item.score);
2654
+ const width = item.score * 10;
2655
+ return `<div class="criterion-card">
2656
+ <div class="criterion-bar"><div class="criterion-bar-fill" style="width:${width}%;background:${color}"></div></div>
2657
+ <span class="criterion-score" style="color:${color}">${item.score}/10</span>
2658
+ <span class="criterion-name">${escapeHtml(item.criterion)}</span>
2659
+ <span class="criterion-status">${escapeHtml(item.status)}</span>
2660
+ </div>`;
2661
+ }).join("\n");
2662
+ const opportunityRows = result.opportunities.map((opp) => {
2663
+ const cls = impactClass(opp.impact);
2664
+ return `<tr>
2665
+ <td>${opp.id}</td>
2666
+ <td>${escapeHtml(opp.name)}</td>
2667
+ <td><span class="impact-badge ${cls}">${escapeHtml(opp.impact)}</span></td>
2668
+ <td>${escapeHtml(opp.effort)}</td>
2669
+ <td>${escapeHtml(opp.description)}</td>
2670
+ </tr>`;
2671
+ }).join("\n");
2672
+ const pagesRows = (result.pagesReviewed || []).map((page) => {
2673
+ const issueCount = page.issues.length;
2674
+ const strengthCount = page.strengths.length;
2675
+ return `<tr>
2676
+ <td>${escapeHtml(page.url)}</td>
2677
+ <td>${escapeHtml(page.category)}</td>
2678
+ <td>${page.wordCount}</td>
2679
+ <td>${issueCount}</td>
2680
+ <td>${strengthCount}</td>
2681
+ </tr>`;
2682
+ }).join("\n");
2683
+ const now = (/* @__PURE__ */ new Date()).toISOString();
2684
+ return `<!DOCTYPE html>
2685
+ <html lang="en">
2686
+ <head>
2687
+ <meta charset="UTF-8">
2688
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
2689
+ <title>AEORank Report - ${domain}</title>
2690
+ <style>${CSS}</style>
2691
+ </head>
2692
+ <body>
2693
+ <div class="container">
2694
+ <div class="header">
2695
+ <h1>${domain}</h1>
2696
+ <div class="date">AEO Audit - ${date}</div>
2697
+ </div>
2698
+
2699
+ <div class="score-section">
2700
+ ${scoreCircleSvg(result.overallScore)}
2701
+ </div>
2702
+
2703
+ <div class="verdict">${escapeHtml(result.verdict)}</div>
2704
+
2705
+ <h2 class="section-title">Scorecard (23 Criteria)</h2>
2706
+ <div class="scorecard-grid">
2707
+ ${scorecardCards}
2708
+ </div>
2709
+
2710
+ ${result.opportunities.length > 0 ? `
2711
+ <h2 class="section-title">Opportunities (${result.opportunities.length})</h2>
2712
+ <table>
2713
+ <thead><tr><th>#</th><th>Opportunity</th><th>Impact</th><th>Effort</th><th>Description</th></tr></thead>
2714
+ <tbody>${opportunityRows}</tbody>
2715
+ </table>
2716
+ ` : ""}
2717
+
2718
+ ${(result.pagesReviewed || []).length > 0 ? `
2719
+ <h2 class="section-title">Pages Reviewed (${(result.pagesReviewed || []).length})</h2>
2720
+ <table>
2721
+ <thead><tr><th>URL</th><th>Category</th><th>Words</th><th>Issues</th><th>Strengths</th></tr></thead>
2722
+ <tbody>${pagesRows}</tbody>
2723
+ </table>
2724
+ ` : ""}
2725
+
2726
+ <div class="bottom-line"><strong>Bottom line:</strong> ${escapeHtml(result.bottomLine)}</div>
2727
+
2728
+ <div class="footer">Generated by AEORank - ${now}</div>
2729
+ </div>
2730
+ </body>
2731
+ </html>`;
2732
+ }
2733
+ function generateComparisonHtmlReport(result) {
2734
+ const domainA = escapeHtml(result.siteA.site);
2735
+ const domainB = escapeHtml(result.siteB.site);
2736
+ const scoreA = result.siteA.overallScore;
2737
+ const scoreB = result.siteB.overallScore;
2738
+ const criteriaRows = result.comparison.criteria.map((c) => {
2739
+ const colorA = criterionColor(c.scoreA);
2740
+ const colorB = criterionColor(c.scoreB);
2741
+ const widthA = c.scoreA * 10;
2742
+ const widthB = c.scoreB * 10;
2743
+ let deltaHtml;
2744
+ if (c.delta > 0) deltaHtml = `<span class="delta-positive">+${c.delta}</span>`;
2745
+ else if (c.delta < 0) deltaHtml = `<span class="delta-negative">${c.delta}</span>`;
2746
+ else deltaHtml = `<span class="delta-zero">0</span>`;
2747
+ return `<tr>
2748
+ <td>${c.id}</td>
2749
+ <td>${escapeHtml(c.criterion)}</td>
2750
+ <td>
2751
+ <div style="display:flex;align-items:center;gap:8px">
2752
+ <div class="criterion-bar"><div class="criterion-bar-fill" style="width:${widthA}%;background:${colorA}"></div></div>
2753
+ <span style="color:${colorA};font-weight:600">${c.scoreA}</span>
2754
+ </div>
2755
+ </td>
2756
+ <td>
2757
+ <div style="display:flex;align-items:center;gap:8px">
2758
+ <div class="criterion-bar"><div class="criterion-bar-fill" style="width:${widthB}%;background:${colorB}"></div></div>
2759
+ <span style="color:${colorB};font-weight:600">${c.scoreB}</span>
2760
+ </div>
2761
+ </td>
2762
+ <td style="text-align:center">${deltaHtml}</td>
2763
+ </tr>`;
2764
+ }).join("\n");
2765
+ const advantagesA = result.comparison.siteAAdvantages.length;
2766
+ const advantagesB = result.comparison.siteBAdvantages.length;
2767
+ const tied = result.comparison.tied.length;
2768
+ const now = (/* @__PURE__ */ new Date()).toISOString();
2769
+ return `<!DOCTYPE html>
2770
+ <html lang="en">
2771
+ <head>
2772
+ <meta charset="UTF-8">
2773
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
2774
+ <title>AEORank Comparison - ${domainA} vs ${domainB}</title>
2775
+ <style>${CSS}</style>
2776
+ </head>
2777
+ <body>
2778
+ <div class="container">
2779
+ <div class="header">
2780
+ <h1>AEO Comparison</h1>
2781
+ </div>
2782
+
2783
+ <div class="compare-header">
2784
+ <div class="compare-site">
2785
+ <h2>${domainA}</h2>
2786
+ ${scoreCircleSvg(scoreA, 120)}
2787
+ </div>
2788
+ <div class="compare-vs">vs</div>
2789
+ <div class="compare-site">
2790
+ <h2>${domainB}</h2>
2791
+ ${scoreCircleSvg(scoreB, 120)}
2792
+ </div>
2793
+ </div>
2794
+
2795
+ <div class="summary-box">
2796
+ <div class="summary-stat">
2797
+ <div class="num" style="color:${scoreColor(scoreA)}">${advantagesA}</div>
2798
+ <div class="label">${domainA} leads</div>
2799
+ </div>
2800
+ <div class="summary-stat">
2801
+ <div class="num" style="color:${scoreColor(scoreB)}">${advantagesB}</div>
2802
+ <div class="label">${domainB} leads</div>
2803
+ </div>
2804
+ <div class="summary-stat">
2805
+ <div class="num" style="color:#999">${tied}</div>
2806
+ <div class="label">Tied</div>
2807
+ </div>
2808
+ </div>
2809
+
2810
+ <h2 class="section-title">Per-Criterion Comparison</h2>
2811
+ <table>
2812
+ <thead>
2813
+ <tr>
2814
+ <th>#</th>
2815
+ <th>Criterion</th>
2816
+ <th>${domainA}</th>
2817
+ <th>${domainB}</th>
2818
+ <th>Delta</th>
2819
+ </tr>
2820
+ </thead>
2821
+ <tbody>${criteriaRows}</tbody>
2822
+ </table>
2823
+
2824
+ ${result.comparison.siteAAdvantages.length > 0 ? `
2825
+ <h2 class="section-title">${domainA} Advantages</h2>
2826
+ <div class="verdict">${result.comparison.siteAAdvantages.map((c) => escapeHtml(c)).join(", ")}</div>
2827
+ ` : ""}
2828
+
2829
+ ${result.comparison.siteBAdvantages.length > 0 ? `
2830
+ <h2 class="section-title">${domainB} Advantages</h2>
2831
+ <div class="verdict">${result.comparison.siteBAdvantages.map((c) => escapeHtml(c)).join(", ")}</div>
2832
+ ` : ""}
2833
+
2834
+ ${result.comparison.tied.length > 0 ? `
2835
+ <h2 class="section-title">Tied Criteria</h2>
2836
+ <div class="verdict">${result.comparison.tied.map((c) => escapeHtml(c)).join(", ")}</div>
2837
+ ` : ""}
2838
+
2839
+ <div class="footer">Generated by AEORank - ${now}</div>
2840
+ </div>
2841
+ </body>
2842
+ </html>`;
2843
+ }
2844
+
2845
+ // src/compare.ts
2846
+ async function compare(domainA, domainB, options) {
2847
+ const [siteA, siteB] = await Promise.all([
2848
+ audit(domainA, options),
2849
+ audit(domainB, options)
2850
+ ]);
2851
+ const criteria = [];
2852
+ const siteAAdvantages = [];
2853
+ const siteBAdvantages = [];
2854
+ const tied = [];
2855
+ for (let i = 0; i < siteA.scorecard.length; i++) {
2856
+ const a = siteA.scorecard[i];
2857
+ const b = siteB.scorecard[i];
2858
+ if (!a || !b) continue;
2859
+ const delta = a.score - b.score;
2860
+ criteria.push({
2861
+ id: a.id,
2862
+ criterion: a.criterion,
2863
+ scoreA: a.score,
2864
+ scoreB: b.score,
2865
+ delta,
2866
+ statusA: a.status,
2867
+ statusB: b.status
2868
+ });
2869
+ if (delta > 0) siteAAdvantages.push(a.criterion);
2870
+ else if (delta < 0) siteBAdvantages.push(a.criterion);
2871
+ else tied.push(a.criterion);
2872
+ }
2873
+ return {
2874
+ siteA,
2875
+ siteB,
2876
+ comparison: {
2877
+ scoreDelta: siteA.overallScore - siteB.overallScore,
2878
+ criteria,
2879
+ siteAAdvantages,
2880
+ siteBAdvantages,
2881
+ tied
2882
+ }
2883
+ };
2884
+ }
2559
2885
  // Annotate the CommonJS export names for ESM import in node:
2560
2886
  0 && (module.exports = {
2561
2887
  CRITERION_LABELS,
@@ -2567,6 +2893,7 @@ async function audit(domain, options) {
2567
2893
  buildScorecard,
2568
2894
  calculateOverallScore,
2569
2895
  classifyRendering,
2896
+ compare,
2570
2897
  detectParkedDomain,
2571
2898
  extractContentPagesFromSitemap,
2572
2899
  extractNavLinks,
@@ -2574,6 +2901,8 @@ async function audit(domain, options) {
2574
2901
  fetchMultiPageData,
2575
2902
  fetchWithHeadless,
2576
2903
  generateBottomLine,
2904
+ generateComparisonHtmlReport,
2905
+ generateHtmlReport,
2577
2906
  generateOpportunities,
2578
2907
  generatePitchNumbers,
2579
2908
  generateVerdict,