@rankcli/agent-runtime 0.0.14 → 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 (199) hide show
  1. package/dist/index.d.mts +77 -393
  2. package/dist/index.d.ts +77 -393
  3. package/dist/index.js +417 -6443
  4. package/dist/index.mjs +296 -6313
  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/ai-citation-worthiness.ts +0 -399
  28. package/src/audit/checks/ai-content-structure.ts +0 -325
  29. package/src/audit/checks/ai-readiness.ts +0 -339
  30. package/src/audit/checks/anchor-text.ts +0 -179
  31. package/src/audit/checks/answer-conciseness.ts +0 -322
  32. package/src/audit/checks/asset-minification.ts +0 -270
  33. package/src/audit/checks/bing-optimization.ts +0 -206
  34. package/src/audit/checks/brand-mention-optimization.ts +0 -349
  35. package/src/audit/checks/caching-headers.ts +0 -305
  36. package/src/audit/checks/canonical-advanced.ts +0 -150
  37. package/src/audit/checks/canonical-domain.ts +0 -196
  38. package/src/audit/checks/citation-quality.ts +0 -358
  39. package/src/audit/checks/client-rendering.ts +0 -542
  40. package/src/audit/checks/color-contrast.ts +0 -342
  41. package/src/audit/checks/content-freshness.ts +0 -170
  42. package/src/audit/checks/content-science.ts +0 -589
  43. package/src/audit/checks/conversion-elements.ts +0 -526
  44. package/src/audit/checks/crawlability.ts +0 -220
  45. package/src/audit/checks/directory-listing.ts +0 -172
  46. package/src/audit/checks/dom-analysis.ts +0 -191
  47. package/src/audit/checks/dom-size.ts +0 -246
  48. package/src/audit/checks/duplicate-content.ts +0 -194
  49. package/src/audit/checks/eeat-signals.ts +0 -990
  50. package/src/audit/checks/entity-seo.ts +0 -396
  51. package/src/audit/checks/featured-snippet.ts +0 -473
  52. package/src/audit/checks/freshness-signals.ts +0 -443
  53. package/src/audit/checks/funnel-intent.ts +0 -463
  54. package/src/audit/checks/hreflang.ts +0 -174
  55. package/src/audit/checks/html-compliance.ts +0 -302
  56. package/src/audit/checks/image-dimensions.ts +0 -167
  57. package/src/audit/checks/images.ts +0 -160
  58. package/src/audit/checks/indexnow.ts +0 -275
  59. package/src/audit/checks/interactive-tools.ts +0 -475
  60. package/src/audit/checks/internal-link-graph.ts +0 -436
  61. package/src/audit/checks/keyword-analysis.ts +0 -239
  62. package/src/audit/checks/keyword-cannibalization.ts +0 -385
  63. package/src/audit/checks/keyword-placement.ts +0 -471
  64. package/src/audit/checks/links.ts +0 -273
  65. package/src/audit/checks/llms-txt.ts +0 -224
  66. package/src/audit/checks/local-seo.ts +0 -296
  67. package/src/audit/checks/mobile.ts +0 -167
  68. package/src/audit/checks/modern-images.ts +0 -226
  69. package/src/audit/checks/navboost-signals.ts +0 -395
  70. package/src/audit/checks/on-page.ts +0 -209
  71. package/src/audit/checks/page-resources.ts +0 -285
  72. package/src/audit/checks/pagination.ts +0 -180
  73. package/src/audit/checks/performance.ts +0 -153
  74. package/src/audit/checks/platform-presence.ts +0 -580
  75. package/src/audit/checks/redirect-analysis.ts +0 -153
  76. package/src/audit/checks/redirect-chain.ts +0 -389
  77. package/src/audit/checks/resource-hints.ts +0 -420
  78. package/src/audit/checks/responsive-css.ts +0 -247
  79. package/src/audit/checks/responsive-images.ts +0 -396
  80. package/src/audit/checks/review-ecosystem.ts +0 -415
  81. package/src/audit/checks/robots-validation.ts +0 -373
  82. package/src/audit/checks/security-headers.ts +0 -188
  83. package/src/audit/checks/security.ts +0 -144
  84. package/src/audit/checks/serp-preview.ts +0 -251
  85. package/src/audit/checks/site-maturity.ts +0 -453
  86. package/src/audit/checks/social-meta.test.ts +0 -275
  87. package/src/audit/checks/social-meta.ts +0 -134
  88. package/src/audit/checks/soft-404.ts +0 -151
  89. package/src/audit/checks/structured-data.ts +0 -238
  90. package/src/audit/checks/tech-detection.ts +0 -496
  91. package/src/audit/checks/topical-clusters.ts +0 -435
  92. package/src/audit/checks/tracker-bloat.ts +0 -462
  93. package/src/audit/checks/tracking-verification.test.ts +0 -371
  94. package/src/audit/checks/tracking-verification.ts +0 -636
  95. package/src/audit/checks/url-safety.ts +0 -682
  96. package/src/audit/deno-entry.ts +0 -66
  97. package/src/audit/discovery/index.ts +0 -15
  98. package/src/audit/discovery/link-crawler.ts +0 -233
  99. package/src/audit/discovery/repo-routes.ts +0 -347
  100. package/src/audit/engine.ts +0 -627
  101. package/src/audit/fixes/index.ts +0 -209
  102. package/src/audit/fixes/social-meta-fixes.test.ts +0 -329
  103. package/src/audit/fixes/social-meta-fixes.ts +0 -463
  104. package/src/audit/index.ts +0 -74
  105. package/src/audit/runner.test.ts +0 -299
  106. package/src/audit/runner.ts +0 -130
  107. package/src/audit/types.ts +0 -1963
  108. package/src/content/featured-snippet.ts +0 -367
  109. package/src/content/generator.test.ts +0 -534
  110. package/src/content/generator.ts +0 -501
  111. package/src/content/headline.ts +0 -317
  112. package/src/content/index.ts +0 -62
  113. package/src/content/intent.ts +0 -258
  114. package/src/content/keyword-density.ts +0 -349
  115. package/src/content/readability.ts +0 -262
  116. package/src/executor.ts +0 -336
  117. package/src/fixer/framework-fixes.test.ts +0 -489
  118. package/src/fixer/framework-fixes.ts +0 -5287
  119. package/src/fixer/index.ts +0 -6
  120. package/src/fixer/schemas.ts +0 -971
  121. package/src/fixer.ts +0 -642
  122. package/src/frameworks/detector.test.ts +0 -248
  123. package/src/frameworks/detector.ts +0 -899
  124. package/src/frameworks/index.ts +0 -68
  125. package/src/frameworks/recipes/angular.yaml +0 -171
  126. package/src/frameworks/recipes/astro.yaml +0 -206
  127. package/src/frameworks/recipes/django.yaml +0 -180
  128. package/src/frameworks/recipes/laravel.yaml +0 -137
  129. package/src/frameworks/recipes/nextjs.yaml +0 -268
  130. package/src/frameworks/recipes/nuxt.yaml +0 -175
  131. package/src/frameworks/recipes/rails.yaml +0 -188
  132. package/src/frameworks/recipes/react.yaml +0 -202
  133. package/src/frameworks/recipes/sveltekit.yaml +0 -154
  134. package/src/frameworks/recipes/vue.yaml +0 -137
  135. package/src/frameworks/recipes/wordpress.yaml +0 -209
  136. package/src/frameworks/suggestion-engine.ts +0 -357
  137. package/src/geo/geo-content.test.ts +0 -305
  138. package/src/geo/geo-content.ts +0 -266
  139. package/src/geo/geo-history.test.ts +0 -473
  140. package/src/geo/geo-history.ts +0 -433
  141. package/src/geo/geo-tracker.test.ts +0 -359
  142. package/src/geo/geo-tracker.ts +0 -411
  143. package/src/geo/index.ts +0 -11
  144. package/src/geo/llm-citation-checker.ts +0 -188
  145. package/src/git/commit-helper.test.ts +0 -261
  146. package/src/git/commit-helper.ts +0 -329
  147. package/src/git/index.ts +0 -12
  148. package/src/git/pr-helper.test.ts +0 -284
  149. package/src/git/pr-helper.ts +0 -307
  150. package/src/index.ts +0 -76
  151. package/src/keywords/ai-keyword-engine.ts +0 -1062
  152. package/src/keywords/ai-summarizer.ts +0 -387
  153. package/src/keywords/ci-mode.ts +0 -555
  154. package/src/keywords/engine.ts +0 -359
  155. package/src/keywords/index.ts +0 -151
  156. package/src/keywords/llm-judge.ts +0 -357
  157. package/src/keywords/nlp-analysis.ts +0 -706
  158. package/src/keywords/prioritizer.ts +0 -295
  159. package/src/keywords/site-crawler.ts +0 -342
  160. package/src/keywords/sources/autocomplete.ts +0 -139
  161. package/src/keywords/sources/competitive-search.ts +0 -450
  162. package/src/keywords/sources/competitor-analysis.ts +0 -374
  163. package/src/keywords/sources/dataforseo.ts +0 -206
  164. package/src/keywords/sources/free-sources.ts +0 -294
  165. package/src/keywords/sources/gsc.ts +0 -123
  166. package/src/keywords/topic-grouping.ts +0 -327
  167. package/src/keywords/types.ts +0 -144
  168. package/src/keywords/wizard.ts +0 -457
  169. package/src/loader.ts +0 -40
  170. package/src/ranking/index.ts +0 -5
  171. package/src/ranking/serp-client.ts +0 -348
  172. package/src/ranking/tracker.ts +0 -380
  173. package/src/ranking/types.ts +0 -123
  174. package/src/reports/index.ts +0 -7
  175. package/src/reports/report-generator.test.ts +0 -293
  176. package/src/reports/report-generator.ts +0 -713
  177. package/src/scheduler/alerts.test.ts +0 -458
  178. package/src/scheduler/alerts.ts +0 -328
  179. package/src/scheduler/index.ts +0 -8
  180. package/src/scheduler/scheduled-audit.test.ts +0 -377
  181. package/src/scheduler/scheduled-audit.ts +0 -149
  182. package/src/test/integration-test.ts +0 -325
  183. package/src/tools/analyzer.ts +0 -373
  184. package/src/tools/crawl.ts +0 -293
  185. package/src/tools/files.ts +0 -301
  186. package/src/tools/h1-fixer.ts +0 -249
  187. package/src/tools/index.ts +0 -67
  188. package/src/tracking/github-action.ts +0 -326
  189. package/src/tracking/google-analytics.ts +0 -265
  190. package/src/tracking/index.ts +0 -45
  191. package/src/tracking/report-generator.ts +0 -386
  192. package/src/tracking/search-console.ts +0 -335
  193. package/src/types.ts +0 -148
  194. package/src/utils/http.ts +0 -302
  195. package/src/wasm-adapter.ts +0 -297
  196. package/src/wasm-entry.ts +0 -14
  197. package/tsconfig.json +0 -17
  198. package/tsup.wasm.config.ts +0 -26
  199. package/vitest.config.ts +0 -15
@@ -1,435 +0,0 @@
1
- // Topical Cluster Analysis - Internal Linking for Topic Authority
2
- // Reference: "4 Steps to Rank #1 in Google (2026 SEO Plan)" by Nathan Gotch
3
- // "Create many supporting assets to train the algorithm to believe we're experts"
4
- // "Cross-link these informational assets together to form a strong cluster"
5
- // "Internally link back out to your commercial page from all these informational assets"
6
-
7
- import * as cheerio from 'cheerio';
8
- import type { AuditIssue } from '../types.js';
9
-
10
- export interface InternalLink {
11
- href: string;
12
- anchorText: string;
13
- context: 'navigation' | 'content' | 'footer' | 'sidebar';
14
- isDoFollow: boolean;
15
- destination: 'internal' | 'external' | 'anchor';
16
- }
17
-
18
- export interface TopicalClusterData {
19
- currentUrl: string;
20
- internalLinks: InternalLink[];
21
- externalLinks: InternalLink[];
22
- anchorLinks: InternalLink[];
23
- linkMetrics: {
24
- totalLinks: number;
25
- internalLinkCount: number;
26
- externalLinkCount: number;
27
- contentLinks: number; // Links within main content (not nav/footer)
28
- uniqueInternalDestinations: number;
29
- avgAnchorTextLength: number;
30
- hasExactMatchAnchors: boolean;
31
- };
32
- clusterSignals: {
33
- hasHubStructure: boolean; // Links to many related pages
34
- hasSpokeLinks: boolean; // Content links back to main topics
35
- hasBreadcrumbs: boolean;
36
- hasRelatedPosts: boolean;
37
- hasCategoryLinks: boolean;
38
- internalToExternalRatio: number;
39
- };
40
- orphanPageRisk: 'low' | 'medium' | 'high';
41
- recommendations: string[];
42
- }
43
-
44
- /**
45
- * Determine link context (nav, content, footer, sidebar)
46
- */
47
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
- function getLinkContext($: cheerio.CheerioAPI, link: cheerio.Cheerio<any>): InternalLink['context'] {
49
- const parents = link.parents().toArray();
50
-
51
- for (const parent of parents) {
52
- const tagName = parent.tagName?.toLowerCase();
53
- const className = ($(parent).attr('class') || '').toLowerCase();
54
- const id = ($(parent).attr('id') || '').toLowerCase();
55
-
56
- // Navigation detection
57
- if (tagName === 'nav' ||
58
- className.includes('nav') ||
59
- className.includes('menu') ||
60
- id.includes('nav') ||
61
- id.includes('menu')) {
62
- return 'navigation';
63
- }
64
-
65
- // Footer detection
66
- if (tagName === 'footer' ||
67
- className.includes('footer') ||
68
- id.includes('footer')) {
69
- return 'footer';
70
- }
71
-
72
- // Sidebar detection
73
- if (tagName === 'aside' ||
74
- className.includes('sidebar') ||
75
- className.includes('widget') ||
76
- id.includes('sidebar')) {
77
- return 'sidebar';
78
- }
79
-
80
- // Main content detection
81
- if (tagName === 'main' ||
82
- tagName === 'article' ||
83
- className.includes('content') ||
84
- className.includes('post') ||
85
- className.includes('entry') ||
86
- id.includes('content')) {
87
- return 'content';
88
- }
89
- }
90
-
91
- return 'content'; // Default to content
92
- }
93
-
94
- /**
95
- * Determine if link is internal, external, or anchor
96
- */
97
- function getLinkDestination(href: string, baseUrl: string): InternalLink['destination'] {
98
- if (!href || href.startsWith('#')) {
99
- return 'anchor';
100
- }
101
-
102
- try {
103
- const linkUrl = new URL(href, baseUrl);
104
- const currentUrl = new URL(baseUrl);
105
-
106
- if (linkUrl.hostname === currentUrl.hostname) {
107
- return 'internal';
108
- }
109
- return 'external';
110
- } catch {
111
- // Relative URL - internal
112
- if (href.startsWith('/') || href.startsWith('./') || href.startsWith('../')) {
113
- return 'internal';
114
- }
115
- return 'external';
116
- }
117
- }
118
-
119
- /**
120
- * Check if link is dofollow (no rel="nofollow")
121
- */
122
- function isDoFollow(rel: string | undefined): boolean {
123
- if (!rel) return true;
124
- const relValues = rel.toLowerCase().split(/\s+/);
125
- return !relValues.includes('nofollow') && !relValues.includes('sponsored') && !relValues.includes('ugc');
126
- }
127
-
128
- /**
129
- * Extract all links from the page
130
- */
131
- export function extractLinks(html: string, url: string): {
132
- internalLinks: InternalLink[];
133
- externalLinks: InternalLink[];
134
- anchorLinks: InternalLink[];
135
- } {
136
- const $ = cheerio.load(html);
137
- const internalLinks: InternalLink[] = [];
138
- const externalLinks: InternalLink[] = [];
139
- const anchorLinks: InternalLink[] = [];
140
-
141
- $('a[href]').each((_, element) => {
142
- const $link = $(element);
143
- const href = $link.attr('href') || '';
144
- const anchorText = $link.text().trim();
145
- const rel = $link.attr('rel');
146
-
147
- const destination = getLinkDestination(href, url);
148
- const context = getLinkContext($, $link);
149
- const doFollow = isDoFollow(rel);
150
-
151
- const link: InternalLink = {
152
- href: href,
153
- anchorText: anchorText,
154
- context,
155
- isDoFollow: doFollow,
156
- destination,
157
- };
158
-
159
- if (destination === 'internal') {
160
- internalLinks.push(link);
161
- } else if (destination === 'external') {
162
- externalLinks.push(link);
163
- } else {
164
- anchorLinks.push(link);
165
- }
166
- });
167
-
168
- return { internalLinks, externalLinks, anchorLinks };
169
- }
170
-
171
- /**
172
- * Detect cluster-related patterns
173
- */
174
- export function detectClusterSignals($: cheerio.CheerioAPI): TopicalClusterData['clusterSignals'] {
175
- // Breadcrumbs detection
176
- const hasBreadcrumbs = $(
177
- '[class*="breadcrumb"], [id*="breadcrumb"], nav[aria-label*="breadcrumb"], ' +
178
- '[itemtype*="BreadcrumbList"], .breadcrumbs'
179
- ).length > 0;
180
-
181
- // Related posts section
182
- const hasRelatedPosts = $(
183
- '[class*="related"], [class*="similar"], [class*="recommended"], ' +
184
- '[id*="related"], h2:contains("Related"), h3:contains("Related"), ' +
185
- 'h2:contains("You might also"), h2:contains("Similar")'
186
- ).length > 0;
187
-
188
- // Category/tag links
189
- const hasCategoryLinks = $(
190
- '[class*="categor"], [class*="tag-"], [rel="tag"], ' +
191
- 'a[href*="/category/"], a[href*="/tag/"], a[href*="/topic/"]'
192
- ).length > 0;
193
-
194
- return {
195
- hasHubStructure: false, // Calculated later
196
- hasSpokeLinks: false, // Calculated later
197
- hasBreadcrumbs,
198
- hasRelatedPosts,
199
- hasCategoryLinks,
200
- internalToExternalRatio: 0, // Calculated later
201
- };
202
- }
203
-
204
- /**
205
- * Calculate orphan page risk based on internal linking
206
- */
207
- function calculateOrphanRisk(
208
- contentLinks: number,
209
- uniqueDestinations: number,
210
- clusterSignals: TopicalClusterData['clusterSignals']
211
- ): TopicalClusterData['orphanPageRisk'] {
212
- let score = 0;
213
-
214
- // Content links to other pages
215
- if (contentLinks >= 5) score += 3;
216
- else if (contentLinks >= 2) score += 2;
217
- else if (contentLinks >= 1) score += 1;
218
-
219
- // Unique destinations (not just linking to homepage)
220
- if (uniqueDestinations >= 5) score += 2;
221
- else if (uniqueDestinations >= 2) score += 1;
222
-
223
- // Cluster signals
224
- if (clusterSignals.hasBreadcrumbs) score += 1;
225
- if (clusterSignals.hasRelatedPosts) score += 2;
226
- if (clusterSignals.hasCategoryLinks) score += 1;
227
-
228
- if (score >= 6) return 'low';
229
- if (score >= 3) return 'medium';
230
- return 'high';
231
- }
232
-
233
- /**
234
- * Main function: Analyze topical cluster structure
235
- */
236
- export function analyzeTopicalClusters(
237
- html: string,
238
- url: string
239
- ): { issues: AuditIssue[]; data: TopicalClusterData } {
240
- const $ = cheerio.load(html);
241
- const issues: AuditIssue[] = [];
242
-
243
- // Extract all links
244
- const { internalLinks, externalLinks, anchorLinks } = extractLinks(html, url);
245
-
246
- // Content-only links (not in nav/footer)
247
- const contentInternalLinks = internalLinks.filter(l => l.context === 'content');
248
- const contentExternalLinks = externalLinks.filter(l => l.context === 'content');
249
-
250
- // Calculate unique internal destinations
251
- const uniqueInternalHrefs = new Set(
252
- internalLinks.map(l => {
253
- try {
254
- return new URL(l.href, url).pathname;
255
- } catch {
256
- return l.href;
257
- }
258
- })
259
- );
260
-
261
- // Calculate average anchor text length
262
- const anchorTexts = internalLinks.filter(l => l.anchorText.length > 0);
263
- const avgAnchorTextLength = anchorTexts.length > 0
264
- ? anchorTexts.reduce((sum, l) => sum + l.anchorText.length, 0) / anchorTexts.length
265
- : 0;
266
-
267
- // Check for exact match anchor text patterns (over-optimization)
268
- const hasExactMatchAnchors = internalLinks.some(l => {
269
- const text = l.anchorText.toLowerCase();
270
- return text.split(' ').length >= 3 && l.context === 'content';
271
- });
272
-
273
- // Detect cluster signals
274
- const clusterSignals = detectClusterSignals($);
275
-
276
- // Calculate internal to external ratio
277
- const totalContentLinks = contentInternalLinks.length + contentExternalLinks.length;
278
- clusterSignals.internalToExternalRatio = totalContentLinks > 0
279
- ? contentInternalLinks.length / totalContentLinks
280
- : 1;
281
-
282
- // Hub structure: many internal links from content
283
- clusterSignals.hasHubStructure = contentInternalLinks.length >= 5;
284
-
285
- // Spoke links: has related posts or category links
286
- clusterSignals.hasSpokeLinks = clusterSignals.hasRelatedPosts || clusterSignals.hasCategoryLinks;
287
-
288
- // Calculate orphan risk
289
- const orphanPageRisk = calculateOrphanRisk(
290
- contentInternalLinks.length,
291
- uniqueInternalHrefs.size,
292
- clusterSignals
293
- );
294
-
295
- // Generate recommendations
296
- const recommendations: string[] = [];
297
-
298
- if (contentInternalLinks.length < 3) {
299
- recommendations.push('Add more contextual internal links within your content');
300
- }
301
-
302
- if (!clusterSignals.hasBreadcrumbs) {
303
- recommendations.push('Add breadcrumb navigation for better site structure');
304
- }
305
-
306
- if (!clusterSignals.hasRelatedPosts) {
307
- recommendations.push('Add a "Related Posts" or "Similar Articles" section');
308
- }
309
-
310
- if (!clusterSignals.hasCategoryLinks) {
311
- recommendations.push('Link to category or topic pages to strengthen clusters');
312
- }
313
-
314
- if (clusterSignals.internalToExternalRatio < 0.5) {
315
- recommendations.push('Balance your link profile - add more internal links');
316
- }
317
-
318
- // Generate issues
319
-
320
- // No internal links in content
321
- if (contentInternalLinks.length === 0) {
322
- issues.push({
323
- code: 'NO_CONTENT_INTERNAL_LINKS',
324
- severity: 'warning',
325
- category: 'on-page',
326
- title: 'No internal links in page content',
327
- description: 'The main content area has no links to other pages on your site.',
328
- impact: 'Internal links help search engines discover pages and understand site structure. They also pass PageRank.',
329
- howToFix: 'Add 3-5 contextual internal links within your content to related pages.',
330
- affectedUrls: [url],
331
- });
332
- } else if (contentInternalLinks.length < 3) {
333
- issues.push({
334
- code: 'FEW_CONTENT_INTERNAL_LINKS',
335
- severity: 'notice',
336
- category: 'on-page',
337
- title: 'Few internal links in content',
338
- description: `Only ${contentInternalLinks.length} internal link(s) in the main content area.`,
339
- impact: 'More contextual internal links strengthen topical clusters and help users discover content.',
340
- howToFix: 'Add relevant internal links where they naturally fit in your content.',
341
- affectedUrls: [url],
342
- details: {
343
- currentCount: contentInternalLinks.length,
344
- recommended: '3-5 minimum',
345
- },
346
- });
347
- }
348
-
349
- // No breadcrumbs
350
- if (!clusterSignals.hasBreadcrumbs) {
351
- issues.push({
352
- code: 'NO_BREADCRUMBS',
353
- severity: 'notice',
354
- category: 'on-page',
355
- title: 'No breadcrumb navigation detected',
356
- description: 'Page lacks breadcrumb navigation for hierarchical context.',
357
- impact: 'Breadcrumbs improve UX, help search engines understand site structure, and can appear in SERPs.',
358
- howToFix: 'Add breadcrumb navigation with Schema.org BreadcrumbList markup.',
359
- affectedUrls: [url],
360
- });
361
- }
362
-
363
- // No related content section
364
- if (!clusterSignals.hasRelatedPosts && !clusterSignals.hasCategoryLinks) {
365
- issues.push({
366
- code: 'NO_RELATED_CONTENT',
367
- severity: 'notice',
368
- category: 'on-page',
369
- title: 'No related content section',
370
- description: 'Page has no "Related Posts" or similar content discovery section.',
371
- impact: 'Related content sections reduce bounce rate, increase pageviews, and strengthen topic clusters.',
372
- howToFix: 'Add a section linking to related articles, products, or category pages.',
373
- affectedUrls: [url],
374
- });
375
- }
376
-
377
- // High orphan page risk
378
- if (orphanPageRisk === 'high') {
379
- issues.push({
380
- code: 'HIGH_ORPHAN_RISK',
381
- severity: 'warning',
382
- category: 'on-page',
383
- title: 'Page may be an orphan page',
384
- description: 'This page has very few internal links, making it hard to discover.',
385
- impact: 'Orphan pages are difficult for search engines to find and may not get indexed.',
386
- howToFix: 'Ensure this page is linked from navigation, category pages, or related content.',
387
- affectedUrls: [url],
388
- details: {
389
- contentLinks: contentInternalLinks.length,
390
- uniqueDestinations: uniqueInternalHrefs.size,
391
- },
392
- });
393
- }
394
-
395
- // Too many external links relative to internal
396
- if (contentExternalLinks.length > contentInternalLinks.length * 2 && contentExternalLinks.length >= 5) {
397
- issues.push({
398
- code: 'EXTERNAL_LINK_HEAVY',
399
- severity: 'notice',
400
- category: 'on-page',
401
- title: 'More external links than internal links',
402
- description: `${contentExternalLinks.length} external links vs ${contentInternalLinks.length} internal links in content.`,
403
- impact: 'While citing sources is good, heavy external linking may dilute PageRank passed to your own pages.',
404
- howToFix: 'Balance external citations with internal links to your own related content.',
405
- affectedUrls: [url],
406
- details: {
407
- externalLinks: contentExternalLinks.length,
408
- internalLinks: contentInternalLinks.length,
409
- ratio: clusterSignals.internalToExternalRatio.toFixed(2),
410
- },
411
- });
412
- }
413
-
414
- return {
415
- issues,
416
- data: {
417
- currentUrl: url,
418
- internalLinks,
419
- externalLinks,
420
- anchorLinks,
421
- linkMetrics: {
422
- totalLinks: internalLinks.length + externalLinks.length + anchorLinks.length,
423
- internalLinkCount: internalLinks.length,
424
- externalLinkCount: externalLinks.length,
425
- contentLinks: contentInternalLinks.length,
426
- uniqueInternalDestinations: uniqueInternalHrefs.size,
427
- avgAnchorTextLength: Math.round(avgAnchorTextLength),
428
- hasExactMatchAnchors,
429
- },
430
- clusterSignals,
431
- orphanPageRisk,
432
- recommendations,
433
- },
434
- };
435
- }