@rankcli/agent-runtime 0.0.15 → 0.0.16

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.
Files changed (202) hide show
  1. package/dist/index.d.mts +43 -393
  2. package/dist/index.d.ts +43 -393
  3. package/dist/index.js +306 -6526
  4. package/dist/index.mjs +202 -6412
  5. package/package.json +6 -1
  6. package/scripts/build-deno.ts +0 -134
  7. package/src/analyzers/core-web-vitals-analyzer.test.ts +0 -236
  8. package/src/analyzers/core-web-vitals-analyzer.ts +0 -557
  9. package/src/analyzers/geo-analyzer.test.ts +0 -310
  10. package/src/analyzers/geo-analyzer.ts +0 -814
  11. package/src/analyzers/image-optimization-analyzer.test.ts +0 -145
  12. package/src/analyzers/image-optimization-analyzer.ts +0 -348
  13. package/src/analyzers/index.ts +0 -233
  14. package/src/analyzers/internal-linking-analyzer.test.ts +0 -141
  15. package/src/analyzers/internal-linking-analyzer.ts +0 -419
  16. package/src/analyzers/mobile-seo-analyzer.test.ts +0 -140
  17. package/src/analyzers/mobile-seo-analyzer.ts +0 -455
  18. package/src/analyzers/security-headers-analyzer.test.ts +0 -115
  19. package/src/analyzers/security-headers-analyzer.ts +0 -318
  20. package/src/analyzers/structured-data-analyzer.test.ts +0 -210
  21. package/src/analyzers/structured-data-analyzer.ts +0 -590
  22. package/src/audit/ai/analyzer.ts +0 -347
  23. package/src/audit/ai/index.ts +0 -29
  24. package/src/audit/ai/prompts/content-analysis.ts +0 -271
  25. package/src/audit/ai/types.ts +0 -179
  26. package/src/audit/checks/additional-checks.ts +0 -439
  27. package/src/audit/checks/agent-experience.ts +0 -108
  28. package/src/audit/checks/ai-citation-worthiness.ts +0 -399
  29. package/src/audit/checks/ai-content-structure.ts +0 -325
  30. package/src/audit/checks/ai-readiness.ts +0 -406
  31. package/src/audit/checks/anchor-text.ts +0 -179
  32. package/src/audit/checks/answer-conciseness.ts +0 -322
  33. package/src/audit/checks/asset-minification.ts +0 -270
  34. package/src/audit/checks/bing-optimization.ts +0 -206
  35. package/src/audit/checks/brand-mention-optimization.ts +0 -349
  36. package/src/audit/checks/caching-headers.ts +0 -305
  37. package/src/audit/checks/canonical-advanced.ts +0 -150
  38. package/src/audit/checks/canonical-domain.ts +0 -196
  39. package/src/audit/checks/citation-quality.ts +0 -358
  40. package/src/audit/checks/client-rendering.ts +0 -542
  41. package/src/audit/checks/color-contrast.ts +0 -342
  42. package/src/audit/checks/content-freshness.ts +0 -170
  43. package/src/audit/checks/content-science.ts +0 -589
  44. package/src/audit/checks/conversion-elements.ts +0 -526
  45. package/src/audit/checks/crawlability.ts +0 -220
  46. package/src/audit/checks/directory-listing.ts +0 -172
  47. package/src/audit/checks/dom-analysis.ts +0 -191
  48. package/src/audit/checks/dom-size.ts +0 -246
  49. package/src/audit/checks/duplicate-content.ts +0 -194
  50. package/src/audit/checks/eeat-signals.ts +0 -990
  51. package/src/audit/checks/entity-seo.ts +0 -396
  52. package/src/audit/checks/featured-snippet.ts +0 -473
  53. package/src/audit/checks/freshness-signals.ts +0 -443
  54. package/src/audit/checks/funnel-intent.ts +0 -463
  55. package/src/audit/checks/hreflang.ts +0 -174
  56. package/src/audit/checks/html-compliance.ts +0 -302
  57. package/src/audit/checks/image-dimensions.ts +0 -167
  58. package/src/audit/checks/images.ts +0 -160
  59. package/src/audit/checks/indexnow.ts +0 -275
  60. package/src/audit/checks/interactive-tools.ts +0 -475
  61. package/src/audit/checks/internal-link-graph.ts +0 -436
  62. package/src/audit/checks/keyword-analysis.ts +0 -239
  63. package/src/audit/checks/keyword-cannibalization.ts +0 -385
  64. package/src/audit/checks/keyword-placement.ts +0 -471
  65. package/src/audit/checks/links.ts +0 -273
  66. package/src/audit/checks/llms-txt.ts +0 -224
  67. package/src/audit/checks/local-seo.ts +0 -296
  68. package/src/audit/checks/mobile.ts +0 -167
  69. package/src/audit/checks/modern-images.ts +0 -226
  70. package/src/audit/checks/navboost-signals.ts +0 -395
  71. package/src/audit/checks/on-page.ts +0 -209
  72. package/src/audit/checks/page-resources.ts +0 -285
  73. package/src/audit/checks/pagination.ts +0 -180
  74. package/src/audit/checks/performance.ts +0 -153
  75. package/src/audit/checks/platform-presence.ts +0 -580
  76. package/src/audit/checks/rag-chunk-readiness.test.ts +0 -159
  77. package/src/audit/checks/rag-chunk-readiness.ts +0 -163
  78. package/src/audit/checks/redirect-analysis.ts +0 -153
  79. package/src/audit/checks/redirect-chain.ts +0 -389
  80. package/src/audit/checks/resource-hints.ts +0 -420
  81. package/src/audit/checks/responsive-css.ts +0 -247
  82. package/src/audit/checks/responsive-images.ts +0 -396
  83. package/src/audit/checks/review-ecosystem.ts +0 -415
  84. package/src/audit/checks/robots-validation.ts +0 -373
  85. package/src/audit/checks/security-headers.ts +0 -188
  86. package/src/audit/checks/security.ts +0 -144
  87. package/src/audit/checks/serp-preview.ts +0 -251
  88. package/src/audit/checks/site-maturity.ts +0 -453
  89. package/src/audit/checks/social-meta.test.ts +0 -275
  90. package/src/audit/checks/social-meta.ts +0 -134
  91. package/src/audit/checks/soft-404.ts +0 -151
  92. package/src/audit/checks/structured-data.ts +0 -238
  93. package/src/audit/checks/tech-detection.ts +0 -496
  94. package/src/audit/checks/topical-clusters.ts +0 -435
  95. package/src/audit/checks/tracker-bloat.ts +0 -462
  96. package/src/audit/checks/tracking-verification.test.ts +0 -371
  97. package/src/audit/checks/tracking-verification.ts +0 -636
  98. package/src/audit/checks/url-safety.ts +0 -682
  99. package/src/audit/deno-entry.ts +0 -66
  100. package/src/audit/discovery/index.ts +0 -15
  101. package/src/audit/discovery/link-crawler.ts +0 -233
  102. package/src/audit/discovery/repo-routes.ts +0 -347
  103. package/src/audit/engine.ts +0 -633
  104. package/src/audit/fixes/index.ts +0 -209
  105. package/src/audit/fixes/social-meta-fixes.test.ts +0 -329
  106. package/src/audit/fixes/social-meta-fixes.ts +0 -463
  107. package/src/audit/index.ts +0 -74
  108. package/src/audit/runner.test.ts +0 -299
  109. package/src/audit/runner.ts +0 -130
  110. package/src/audit/types.ts +0 -1987
  111. package/src/content/featured-snippet.ts +0 -367
  112. package/src/content/generator.test.ts +0 -534
  113. package/src/content/generator.ts +0 -501
  114. package/src/content/headline.ts +0 -317
  115. package/src/content/index.ts +0 -62
  116. package/src/content/intent.ts +0 -258
  117. package/src/content/keyword-density.ts +0 -349
  118. package/src/content/readability.ts +0 -262
  119. package/src/executor.ts +0 -336
  120. package/src/fixer/framework-fixes.test.ts +0 -489
  121. package/src/fixer/framework-fixes.ts +0 -5287
  122. package/src/fixer/index.ts +0 -6
  123. package/src/fixer/schemas.ts +0 -971
  124. package/src/fixer.ts +0 -642
  125. package/src/frameworks/detector.test.ts +0 -248
  126. package/src/frameworks/detector.ts +0 -899
  127. package/src/frameworks/index.ts +0 -68
  128. package/src/frameworks/recipes/angular.yaml +0 -171
  129. package/src/frameworks/recipes/astro.yaml +0 -206
  130. package/src/frameworks/recipes/django.yaml +0 -180
  131. package/src/frameworks/recipes/laravel.yaml +0 -137
  132. package/src/frameworks/recipes/nextjs.yaml +0 -268
  133. package/src/frameworks/recipes/nuxt.yaml +0 -175
  134. package/src/frameworks/recipes/rails.yaml +0 -188
  135. package/src/frameworks/recipes/react.yaml +0 -202
  136. package/src/frameworks/recipes/sveltekit.yaml +0 -154
  137. package/src/frameworks/recipes/vue.yaml +0 -137
  138. package/src/frameworks/recipes/wordpress.yaml +0 -209
  139. package/src/frameworks/suggestion-engine.ts +0 -357
  140. package/src/geo/geo-content.test.ts +0 -305
  141. package/src/geo/geo-content.ts +0 -266
  142. package/src/geo/geo-history.test.ts +0 -473
  143. package/src/geo/geo-history.ts +0 -433
  144. package/src/geo/geo-tracker.test.ts +0 -359
  145. package/src/geo/geo-tracker.ts +0 -411
  146. package/src/geo/index.ts +0 -11
  147. package/src/geo/llm-citation-checker.ts +0 -188
  148. package/src/git/commit-helper.test.ts +0 -261
  149. package/src/git/commit-helper.ts +0 -329
  150. package/src/git/index.ts +0 -12
  151. package/src/git/pr-helper.test.ts +0 -284
  152. package/src/git/pr-helper.ts +0 -307
  153. package/src/index.ts +0 -76
  154. package/src/keywords/ai-keyword-engine.ts +0 -1062
  155. package/src/keywords/ai-summarizer.ts +0 -387
  156. package/src/keywords/ci-mode.ts +0 -555
  157. package/src/keywords/engine.ts +0 -359
  158. package/src/keywords/index.ts +0 -151
  159. package/src/keywords/llm-judge.ts +0 -357
  160. package/src/keywords/nlp-analysis.ts +0 -706
  161. package/src/keywords/prioritizer.ts +0 -295
  162. package/src/keywords/site-crawler.ts +0 -342
  163. package/src/keywords/sources/autocomplete.ts +0 -139
  164. package/src/keywords/sources/competitive-search.ts +0 -450
  165. package/src/keywords/sources/competitor-analysis.ts +0 -374
  166. package/src/keywords/sources/dataforseo.ts +0 -206
  167. package/src/keywords/sources/free-sources.ts +0 -294
  168. package/src/keywords/sources/gsc.ts +0 -123
  169. package/src/keywords/topic-grouping.ts +0 -327
  170. package/src/keywords/types.ts +0 -144
  171. package/src/keywords/wizard.ts +0 -457
  172. package/src/loader.ts +0 -40
  173. package/src/ranking/index.ts +0 -5
  174. package/src/ranking/serp-client.ts +0 -348
  175. package/src/ranking/tracker.ts +0 -380
  176. package/src/ranking/types.ts +0 -123
  177. package/src/reports/index.ts +0 -7
  178. package/src/reports/report-generator.test.ts +0 -293
  179. package/src/reports/report-generator.ts +0 -713
  180. package/src/scheduler/alerts.test.ts +0 -458
  181. package/src/scheduler/alerts.ts +0 -328
  182. package/src/scheduler/index.ts +0 -8
  183. package/src/scheduler/scheduled-audit.test.ts +0 -377
  184. package/src/scheduler/scheduled-audit.ts +0 -149
  185. package/src/test/integration-test.ts +0 -325
  186. package/src/tools/analyzer.ts +0 -373
  187. package/src/tools/crawl.ts +0 -293
  188. package/src/tools/files.ts +0 -301
  189. package/src/tools/h1-fixer.ts +0 -249
  190. package/src/tools/index.ts +0 -67
  191. package/src/tracking/github-action.ts +0 -326
  192. package/src/tracking/google-analytics.ts +0 -265
  193. package/src/tracking/index.ts +0 -45
  194. package/src/tracking/report-generator.ts +0 -386
  195. package/src/tracking/search-console.ts +0 -335
  196. package/src/types.ts +0 -148
  197. package/src/utils/http.ts +0 -302
  198. package/src/wasm-adapter.ts +0 -297
  199. package/src/wasm-entry.ts +0 -14
  200. package/tsconfig.json +0 -17
  201. package/tsup.wasm.config.ts +0 -26
  202. package/vitest.config.ts +0 -15
@@ -1,542 +0,0 @@
1
- // Client-Side Rendering Detection - SSR/SSG is critical for SEO
2
- // Reference: "Technical SEO for Developers - 17 Tips to Rank Higher"
3
- // "The page should load its content even if I have JavaScript disabled"
4
- // "Statically generating or server-side rendering is so much safer than rendering only on the client"
5
-
6
- import * as cheerio from 'cheerio';
7
- import type { AuditIssue } from '../types.js';
8
-
9
- export interface RenderingAnalysis {
10
- renderingMethod: 'ssr' | 'ssg' | 'csr' | 'hybrid' | 'unknown';
11
- confidence: 'high' | 'medium' | 'low';
12
- signals: RenderingSignal[];
13
- frameworkDetected: string | null;
14
- hasContentInHTML: boolean;
15
- hasHydrationMarkers: boolean;
16
- hasClientOnlyIndicators: boolean;
17
- mainContentCharCount: number;
18
- recommendations: string[];
19
- metaManagement: string | null; // React Helmet, Vue Meta, etc.
20
- hasDynamicMetaTags: boolean;
21
- // AI-specific content accessibility metrics
22
- aiAccessibility: {
23
- htmlContentRatio: number; // % of content in raw HTML vs total expected
24
- hasSemanticStructure: boolean; // Proper heading hierarchy, landmarks
25
- keyContentInHTML: boolean; // Title, main headings, first paragraphs in HTML
26
- aiReadableScore: number; // 0-100 score for AI parsing ability
27
- };
28
- }
29
-
30
- export interface RenderingSignal {
31
- indicator: string;
32
- suggests: 'ssr' | 'ssg' | 'csr';
33
- weight: number;
34
- }
35
-
36
- // Framework detection patterns
37
- const FRAMEWORK_PATTERNS: Record<string, RegExp[]> = {
38
- 'Next.js': [/__NEXT_DATA__/, /next\//, /_next\//],
39
- 'Nuxt': [/__NUXT__/, /nuxt/, /_nuxt\//],
40
- 'Gatsby': [/___gatsby/, /gatsby-/, /gatsby-image/],
41
- 'Remix': [/__remix/, /remix/],
42
- 'SvelteKit': [/__sveltekit/, /svelte/],
43
- 'Angular Universal': [/ng-version/, /angular/],
44
- 'React': [/react-root/, /data-reactroot/, /__REACT/],
45
- 'Vue': [/data-v-/, /Vue\./, /__VUE/],
46
- 'Astro': [/astro-/, /astro:/],
47
- };
48
-
49
- // Meta tag management patterns (React Helmet, etc.)
50
- const META_MANAGEMENT_PATTERNS = [
51
- { name: 'React Helmet', pattern: /data-react-helmet/i },
52
- { name: 'Next.js Head', pattern: /__NEXT_DATA__.*"head"/i },
53
- { name: 'Vue Meta', pattern: /data-vue-meta/i },
54
- { name: 'Nuxt Head', pattern: /__NUXT__.*"head"/i },
55
- { name: 'Remix Meta', pattern: /__remix_meta/i },
56
- ];
57
-
58
- // Indicators of client-side only rendering (bad for SEO)
59
- const CSR_INDICATORS = [
60
- // Empty root elements waiting for JS to populate
61
- { pattern: /<div id="root"><\/div>/i, weight: 3 },
62
- { pattern: /<div id="app"><\/div>/i, weight: 3 },
63
- { pattern: /<div id="__next"><\/div>/i, weight: 2 }, // Empty Next.js (should have content)
64
- { pattern: /<div id="__nuxt"><\/div>/i, weight: 2 }, // Empty Nuxt
65
- { pattern: /<main><\/main>/i, weight: 2 },
66
- { pattern: /<article><\/article>/i, weight: 2 },
67
-
68
- // Noscript warnings indicating JS dependency
69
- { pattern: /<noscript>.*(?:enable|require|need).*javascript/i, weight: 3 },
70
- { pattern: /<noscript>.*(?:won't work|doesn't work)/i, weight: 3 },
71
-
72
- // Very minimal HTML body
73
- { pattern: /<body[^>]*>\s*<(?:div|script)[^>]*>\s*<\/(?:div|script)>\s*<\/body>/i, weight: 4 },
74
-
75
- // Loading spinners/states in initial HTML
76
- { pattern: /class="[^"]*loading[^"]*"/i, weight: 1 },
77
- { pattern: /Loading\.\.\./i, weight: 1 },
78
-
79
- // Client-only component indicators
80
- { pattern: /data-client-only/i, weight: 2 },
81
- { pattern: /client:only/i, weight: 2 }, // Astro client:only
82
- ];
83
-
84
- // Indicators of server-side rendering (good for SEO)
85
- const SSR_INDICATORS = [
86
- // Hydration markers (content was rendered server-side)
87
- { pattern: /__NEXT_DATA__/, weight: 3 },
88
- { pattern: /__NUXT__/, weight: 3 },
89
- { pattern: /data-reactroot/, weight: 2 },
90
- { pattern: /data-server-rendered/, weight: 3 },
91
-
92
- // Pre-rendered content indicators
93
- { pattern: /<h1[^>]*>[^<]+<\/h1>/i, weight: 2 },
94
- { pattern: /<article[^>]*>[^<]{100,}/i, weight: 3 },
95
- { pattern: /<main[^>]*>[^<]{100,}/i, weight: 3 },
96
-
97
- // Meta content (usually server-rendered)
98
- { pattern: /<meta property="og:title"[^>]*content="[^"]+"/, weight: 1 },
99
- { pattern: /<meta name="description"[^>]*content="[^"]+"/, weight: 1 },
100
-
101
- // Structured data
102
- { pattern: /<script type="application\/ld\+json">/, weight: 2 },
103
- ];
104
-
105
- /**
106
- * Detect framework from HTML
107
- */
108
- export function detectFramework(html: string): string | null {
109
- for (const [framework, patterns] of Object.entries(FRAMEWORK_PATTERNS)) {
110
- for (const pattern of patterns) {
111
- if (pattern.test(html)) {
112
- return framework;
113
- }
114
- }
115
- }
116
- return null;
117
- }
118
-
119
- /**
120
- * Analyze HTML to determine rendering method
121
- */
122
- export function analyzeRendering(html: string): RenderingAnalysis {
123
- const $ = cheerio.load(html);
124
- const signals: RenderingSignal[] = [];
125
-
126
- // Detect framework
127
- const frameworkDetected = detectFramework(html);
128
-
129
- // Check for CSR indicators
130
- let csrScore = 0;
131
- for (const indicator of CSR_INDICATORS) {
132
- if (indicator.pattern.test(html)) {
133
- csrScore += indicator.weight;
134
- signals.push({
135
- indicator: indicator.pattern.toString(),
136
- suggests: 'csr',
137
- weight: indicator.weight,
138
- });
139
- }
140
- }
141
-
142
- // Check for SSR indicators
143
- let ssrScore = 0;
144
- for (const indicator of SSR_INDICATORS) {
145
- if (indicator.pattern.test(html)) {
146
- ssrScore += indicator.weight;
147
- signals.push({
148
- indicator: indicator.pattern.toString(),
149
- suggests: 'ssr',
150
- weight: indicator.weight,
151
- });
152
- }
153
- }
154
-
155
- // Analyze main content
156
- const mainContent = $('main, article, [role="main"], .content, #content').text();
157
- const bodyText = $('body').text().replace(/\s+/g, ' ').trim();
158
- const mainContentCharCount = mainContent.length || bodyText.length;
159
-
160
- // Very little text content is a red flag
161
- const hasContentInHTML = mainContentCharCount > 200;
162
- if (!hasContentInHTML) {
163
- csrScore += 4;
164
- signals.push({
165
- indicator: `Body text only ${mainContentCharCount} chars`,
166
- suggests: 'csr',
167
- weight: 4,
168
- });
169
- } else {
170
- ssrScore += 2;
171
- }
172
-
173
- // Check for hydration markers
174
- const hasHydrationMarkers =
175
- /__NEXT_DATA__|__NUXT__|data-reactroot|data-server-rendered/.test(html);
176
-
177
- // Check for client-only indicators
178
- const hasClientOnlyIndicators = $('[data-client-only], [client\\:only]').length > 0;
179
-
180
- // Detect meta tag management library
181
- let metaManagement: string | null = null;
182
- for (const { name, pattern } of META_MANAGEMENT_PATTERNS) {
183
- if (pattern.test(html)) {
184
- metaManagement = name;
185
- break;
186
- }
187
- }
188
-
189
- // Check if meta tags appear to be dynamically managed
190
- const hasDynamicMetaTags = metaManagement !== null ||
191
- $('meta[data-react-helmet]').length > 0 ||
192
- $('meta[data-vue-meta]').length > 0;
193
-
194
- // === AI ACCESSIBILITY ANALYSIS ===
195
- // AI systems (ChatGPT, Claude, etc.) primarily read raw HTML
196
- // Content hidden behind JavaScript may not be indexed by AI
197
-
198
- // Check semantic structure
199
- const hasH1 = $('h1').length > 0 && $('h1').text().trim().length > 0;
200
- const hasH2 = $('h2').length > 0;
201
- const hasMain = $('main, [role="main"]').length > 0;
202
- const hasArticle = $('article').length > 0;
203
- const hasSemanticStructure = hasH1 && (hasMain || hasArticle);
204
-
205
- // Check if key content is in HTML
206
- const title = $('title').text().trim();
207
- const h1Text = $('h1').first().text().trim();
208
- const firstParagraph = $('p').first().text().trim();
209
-
210
- const keyContentInHTML =
211
- title.length > 10 &&
212
- h1Text.length > 5 &&
213
- firstParagraph.length > 50;
214
-
215
- // Calculate HTML content ratio
216
- // Compare actual content to expected minimum for a meaningful page
217
- const EXPECTED_MIN_CONTENT = 1000; // Minimum expected chars for a content page
218
- const htmlContentRatio = Math.min(100, (mainContentCharCount / EXPECTED_MIN_CONTENT) * 100);
219
-
220
- // Calculate AI readable score
221
- let aiReadableScore = 50; // Base score
222
-
223
- // Content amount
224
- if (mainContentCharCount > 2000) aiReadableScore += 20;
225
- else if (mainContentCharCount > 1000) aiReadableScore += 15;
226
- else if (mainContentCharCount > 500) aiReadableScore += 10;
227
- else if (mainContentCharCount < 200) aiReadableScore -= 20;
228
-
229
- // Semantic structure
230
- if (hasSemanticStructure) aiReadableScore += 15;
231
- if (hasH1 && hasH2) aiReadableScore += 5;
232
-
233
- // Key content in HTML
234
- if (keyContentInHTML) aiReadableScore += 15;
235
- else aiReadableScore -= 10;
236
-
237
- // SSR/SSG bonus
238
- if (hasHydrationMarkers || ssrScore > csrScore) aiReadableScore += 10;
239
-
240
- // CSR penalty
241
- if (csrScore > ssrScore + 3) aiReadableScore -= 20;
242
-
243
- aiReadableScore = Math.max(0, Math.min(100, aiReadableScore));
244
-
245
- const aiAccessibility = {
246
- htmlContentRatio: Math.round(htmlContentRatio),
247
- hasSemanticStructure,
248
- keyContentInHTML,
249
- aiReadableScore,
250
- };
251
-
252
- // Determine rendering method
253
- let renderingMethod: 'ssr' | 'ssg' | 'csr' | 'hybrid' | 'unknown';
254
- let confidence: 'high' | 'medium' | 'low';
255
-
256
- if (csrScore > ssrScore + 3) {
257
- renderingMethod = 'csr';
258
- confidence = csrScore - ssrScore > 6 ? 'high' : 'medium';
259
- } else if (ssrScore > csrScore + 3) {
260
- // Distinguish SSG from SSR (static has specific patterns)
261
- const isLikelyStatic =
262
- html.includes('data-gatsby') ||
263
- html.includes('astro-') ||
264
- (!html.includes('__NEXT_DATA__') && !html.includes('__NUXT__'));
265
-
266
- renderingMethod = isLikelyStatic ? 'ssg' : 'ssr';
267
- confidence = ssrScore - csrScore > 6 ? 'high' : 'medium';
268
- } else if (hasHydrationMarkers && hasClientOnlyIndicators) {
269
- renderingMethod = 'hybrid';
270
- confidence = 'medium';
271
- } else {
272
- renderingMethod = 'unknown';
273
- confidence = 'low';
274
- }
275
-
276
- // Generate recommendations
277
- const recommendations = generateRecommendations(
278
- renderingMethod,
279
- hasContentInHTML,
280
- mainContentCharCount,
281
- frameworkDetected
282
- );
283
-
284
- return {
285
- renderingMethod,
286
- confidence,
287
- signals,
288
- frameworkDetected,
289
- hasContentInHTML,
290
- hasHydrationMarkers,
291
- hasClientOnlyIndicators,
292
- mainContentCharCount,
293
- recommendations,
294
- metaManagement,
295
- hasDynamicMetaTags,
296
- aiAccessibility,
297
- };
298
- }
299
-
300
- function generateRecommendations(
301
- renderingMethod: string,
302
- hasContentInHTML: boolean,
303
- charCount: number,
304
- framework: string | null
305
- ): string[] {
306
- const recommendations: string[] = [];
307
-
308
- if (renderingMethod === 'csr') {
309
- recommendations.push(
310
- 'Critical: Pre-render your pages so crawlers see actual content in the HTML'
311
- );
312
-
313
- if (framework === 'React') {
314
- recommendations.push(
315
- 'Quick fix: Use Vike (vike.dev) for SSR/SSG - works with Vite, minimal config needed'
316
- );
317
- recommendations.push(
318
- 'Alternative: Migrate to Next.js or Remix for built-in SSR/SSG support'
319
- );
320
- } else if (framework === 'Vue') {
321
- recommendations.push(
322
- 'Quick fix: Use Vike (vike.dev) for SSR/SSG - works with Vite, minimal config needed'
323
- );
324
- recommendations.push(
325
- 'Alternative: Migrate to Nuxt for built-in SSR/SSG support'
326
- );
327
- } else if (framework === 'Angular Universal') {
328
- recommendations.push(
329
- 'Enable Angular Universal for server-side rendering'
330
- );
331
- } else {
332
- recommendations.push(
333
- 'Quick fix: Use Vike (vike.dev) for SSR/SSG with any Vite-based framework'
334
- );
335
- }
336
-
337
- recommendations.push(
338
- 'Google can render JavaScript, but pre-rendered HTML is more reliable and faster to index'
339
- );
340
- }
341
-
342
- if (!hasContentInHTML) {
343
- recommendations.push(
344
- `Very little content in initial HTML (${charCount} chars). Search engines may not see your content.`
345
- );
346
- }
347
-
348
- if (renderingMethod === 'hybrid') {
349
- recommendations.push(
350
- 'Hybrid rendering detected. Ensure critical SEO content is server-rendered, not client-only.'
351
- );
352
- }
353
-
354
- return recommendations;
355
- }
356
-
357
- /**
358
- * Main function: Analyze page rendering method for SEO
359
- */
360
- export function analyzeClientRendering(
361
- html: string,
362
- url: string
363
- ): { issues: AuditIssue[]; data: RenderingAnalysis } {
364
- const $ = cheerio.load(html);
365
- const issues: AuditIssue[] = [];
366
- const analysis = analyzeRendering(html);
367
-
368
- // Critical: Client-side only rendering
369
- if (analysis.renderingMethod === 'csr' && analysis.confidence !== 'low') {
370
- const howToFixByFramework = analysis.frameworkDetected === 'React'
371
- ? 'Use Vike (vike.dev) to add SSR/SSG to your Vite React app: npm install vike vike-react, then follow the setup guide. Alternatively, migrate to Next.js or Remix.'
372
- : analysis.frameworkDetected === 'Vue'
373
- ? 'Use Vike (vike.dev) to add SSR/SSG to your Vite Vue app: npm install vike vike-vue, then follow the setup guide. Alternatively, migrate to Nuxt.'
374
- : 'Use Vike (vike.dev) for SSR/SSG with Vite-based frameworks, or use a framework with built-in SSR support (Next.js, Nuxt, Remix, SvelteKit).';
375
-
376
- issues.push({
377
- code: 'CLIENT_SIDE_RENDERING',
378
- severity: 'error',
379
- category: 'crawlability',
380
- title: 'Page relies on client-side rendering',
381
- description:
382
- 'This page appears to render content primarily via JavaScript. Search engines may not see your content.',
383
- impact:
384
- 'Google can execute JavaScript but it\'s slower and less reliable. Content may not be indexed properly.',
385
- howToFix: howToFixByFramework,
386
- affectedUrls: [url],
387
- details: {
388
- confidence: analysis.confidence,
389
- framework: analysis.frameworkDetected,
390
- signals: analysis.signals.filter(s => s.suggests === 'csr').slice(0, 5),
391
- },
392
- });
393
- }
394
-
395
- // Warning: Very little content in HTML
396
- if (!analysis.hasContentInHTML) {
397
- issues.push({
398
- code: 'EMPTY_BODY_CONTENT',
399
- severity: 'error',
400
- category: 'content',
401
- title: 'Very little content in initial HTML',
402
- description:
403
- `Only ${analysis.mainContentCharCount} characters of text found in the HTML. Content may be loaded via JavaScript.`,
404
- impact:
405
- 'Search engines prioritize content in the initial HTML response. JavaScript-loaded content may be missed or delayed.',
406
- howToFix:
407
- 'Ensure main page content is present in the server-rendered HTML, not loaded via JavaScript after page load.',
408
- affectedUrls: [url],
409
- details: {
410
- charCount: analysis.mainContentCharCount,
411
- renderingMethod: analysis.renderingMethod,
412
- },
413
- });
414
- }
415
-
416
- // Notice: Framework without SSR evidence
417
- if (
418
- analysis.frameworkDetected &&
419
- ['React', 'Vue'].includes(analysis.frameworkDetected) &&
420
- !analysis.hasHydrationMarkers &&
421
- analysis.mainContentCharCount < 500
422
- ) {
423
- issues.push({
424
- code: 'SPA_WITHOUT_SSR',
425
- severity: 'warning',
426
- category: 'crawlability',
427
- title: `${analysis.frameworkDetected} detected without SSR markers`,
428
- description:
429
- `This appears to be a ${analysis.frameworkDetected} SPA without server-side rendering enabled.`,
430
- impact:
431
- 'Single Page Applications without SSR have slower time-to-content for search crawlers.',
432
- howToFix:
433
- analysis.frameworkDetected === 'React'
434
- ? 'Add SSR/SSG using Vike (vike.dev): npm install vike vike-react. Alternative: migrate to Next.js or Remix.'
435
- : 'Add SSR/SSG using Vike (vike.dev): npm install vike vike-vue. Alternative: migrate to Nuxt.',
436
- affectedUrls: [url],
437
- details: {
438
- framework: analysis.frameworkDetected,
439
- hasHydrationMarkers: analysis.hasHydrationMarkers,
440
- },
441
- });
442
- }
443
-
444
- // Notice: Static generation recommended
445
- if (
446
- analysis.renderingMethod === 'ssr' &&
447
- analysis.confidence !== 'low'
448
- ) {
449
- // Not an issue, but we could suggest SSG for better performance
450
- // This is informational only
451
- }
452
-
453
- // Warning: React/Vue without meta management library
454
- if (
455
- analysis.frameworkDetected &&
456
- ['React', 'Vue'].includes(analysis.frameworkDetected) &&
457
- !analysis.hasDynamicMetaTags &&
458
- analysis.renderingMethod !== 'csr' // Don't double-warn for CSR
459
- ) {
460
- const helmetLib = analysis.frameworkDetected === 'React' ? 'React Helmet' : 'Vue Meta';
461
- const metaTagsPresent = $('meta[name="description"], meta[property="og:title"]').length > 0;
462
-
463
- if (!metaTagsPresent) {
464
- issues.push({
465
- code: 'SPA_NO_META_MANAGEMENT',
466
- severity: 'warning',
467
- category: 'on-page',
468
- title: `${analysis.frameworkDetected} app may lack dynamic meta tag management`,
469
- description:
470
- `No ${helmetLib} or similar library detected for managing meta tags in this SPA.`,
471
- impact:
472
- 'SPAs need dynamic meta tag management for proper page-specific titles, descriptions, and social tags.',
473
- howToFix:
474
- analysis.frameworkDetected === 'React'
475
- ? 'Use React Helmet, Next.js Head, or Remix meta exports for dynamic meta tags.'
476
- : 'Use Vue Meta, Nuxt Head, or vue-head for dynamic meta tags.',
477
- affectedUrls: [url],
478
- details: {
479
- framework: analysis.frameworkDetected,
480
- metaManagement: analysis.metaManagement,
481
- },
482
- });
483
- }
484
- }
485
-
486
- // === AI-SPECIFIC CONTENT ACCESSIBILITY CHECKS ===
487
-
488
- // Low AI readable score
489
- if (analysis.aiAccessibility.aiReadableScore < 50) {
490
- issues.push({
491
- code: 'AI_LOW_HTML_READABILITY',
492
- severity: 'warning',
493
- category: 'ai-readiness',
494
- title: 'Content not optimally accessible to AI systems',
495
- description: `AI readability score: ${analysis.aiAccessibility.aiReadableScore}/100. AI systems like ChatGPT primarily read raw HTML and may miss JavaScript-rendered content.`,
496
- impact: 'Content may not be properly indexed by AI search systems (ChatGPT, Perplexity, etc.), reducing AI citation likelihood.',
497
- howToFix: 'Ensure key content is in the initial HTML response: 1) Use SSR/SSG, 2) Include title, H1, and main content in HTML, 3) Don\'t hide content behind JavaScript interactions.',
498
- affectedUrls: [url],
499
- details: {
500
- aiReadableScore: analysis.aiAccessibility.aiReadableScore,
501
- htmlContentRatio: analysis.aiAccessibility.htmlContentRatio,
502
- hasSemanticStructure: analysis.aiAccessibility.hasSemanticStructure,
503
- keyContentInHTML: analysis.aiAccessibility.keyContentInHTML,
504
- },
505
- });
506
- }
507
-
508
- // Missing semantic structure for AI
509
- if (!analysis.aiAccessibility.hasSemanticStructure && analysis.mainContentCharCount > 500) {
510
- issues.push({
511
- code: 'AI_NO_SEMANTIC_STRUCTURE',
512
- severity: 'notice',
513
- category: 'ai-readiness',
514
- title: 'Content lacks semantic HTML structure for AI parsing',
515
- description: 'Missing semantic landmarks (<main>, <article>) or heading hierarchy. AI systems use these to identify and extract key content.',
516
- impact: 'AI may not correctly identify the main content area, potentially extracting navigation or footer text instead.',
517
- howToFix: 'Add semantic HTML: wrap main content in <main> or <article>, ensure H1 exists and heading hierarchy is logical (H1 → H2 → H3).',
518
- affectedUrls: [url],
519
- });
520
- }
521
-
522
- // Key content not in initial HTML
523
- if (!analysis.aiAccessibility.keyContentInHTML && analysis.renderingMethod !== 'csr') {
524
- issues.push({
525
- code: 'AI_KEY_CONTENT_NOT_IN_HTML',
526
- severity: 'warning',
527
- category: 'ai-readiness',
528
- title: 'Key content elements missing from initial HTML',
529
- description: 'Title, H1, or opening paragraph content is missing or too short in the HTML. AI systems extract these first.',
530
- impact: 'AI may not have access to your primary message, reducing chances of accurate citation.',
531
- howToFix: 'Ensure the initial HTML contains: meaningful <title>, descriptive <h1>, and a substantial first paragraph with your key message.',
532
- affectedUrls: [url],
533
- details: {
534
- hasTitle: $('title').text().trim().length > 10,
535
- hasH1: $('h1').text().trim().length > 5,
536
- hasFirstParagraph: $('p').first().text().trim().length > 50,
537
- },
538
- });
539
- }
540
-
541
- return { issues, data: analysis };
542
- }