@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,419 +0,0 @@
1
- /**
2
- * Internal Linking Analyzer
3
- *
4
- * Analyzes internal link structure for SEO optimization.
5
- * Checks link distribution, anchor text, orphan pages, and link depth.
6
- */
7
-
8
- import * as cheerio from 'cheerio';
9
- import type { AuditIssue } from '../audit/types.js';
10
-
11
- export interface InternalLinkingResult {
12
- score: number;
13
- totalLinks: number;
14
- internalLinks: number;
15
- externalLinks: number;
16
- navigationLinks: number;
17
- contentLinks: number;
18
- uniqueInternalTargets: number;
19
- linksWithKeywords: number;
20
- linksWithGenericText: number;
21
- orphanRisk: boolean;
22
- linkDetails: LinkInfo[];
23
- anchorTextAnalysis: AnchorTextStats;
24
- issues: AuditIssue[];
25
- recommendations: string[];
26
- }
27
-
28
- export interface LinkInfo {
29
- href: string;
30
- text: string;
31
- isInternal: boolean;
32
- isNavigation: boolean;
33
- rel?: string;
34
- title?: string;
35
- issues: string[];
36
- }
37
-
38
- export interface AnchorTextStats {
39
- total: number;
40
- descriptive: number;
41
- generic: number;
42
- empty: number;
43
- tooLong: number;
44
- imageLinks: number;
45
- patterns: { text: string; count: number }[];
46
- }
47
-
48
- const GENERIC_ANCHOR_TEXTS = [
49
- 'click here',
50
- 'read more',
51
- 'learn more',
52
- 'here',
53
- 'link',
54
- 'this',
55
- 'more',
56
- 'continue',
57
- 'see more',
58
- 'view more',
59
- 'details',
60
- 'go',
61
- 'continue reading',
62
- '>>',
63
- '→',
64
- 'next',
65
- 'previous',
66
- ];
67
-
68
- /**
69
- * Check if URL is internal
70
- */
71
- function isInternalUrl(href: string, baseUrl: string): boolean {
72
- if (!href || href.startsWith('#') || href.startsWith('javascript:') || href.startsWith('mailto:') || href.startsWith('tel:')) {
73
- return false;
74
- }
75
-
76
- if (href.startsWith('/') && !href.startsWith('//')) {
77
- return true;
78
- }
79
-
80
- try {
81
- const base = new URL(baseUrl);
82
- const link = new URL(href, baseUrl);
83
- return link.hostname === base.hostname;
84
- } catch {
85
- return false;
86
- }
87
- }
88
-
89
- /**
90
- * Check if link is in navigation
91
- */
92
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
93
- function isNavigationLink($el: cheerio.Cheerio<any>, $: cheerio.CheerioAPI): boolean {
94
- const parent = $el.parents('nav, header, footer, [role="navigation"], .nav, .navigation, .menu, .sidebar').first();
95
- return parent.length > 0;
96
- }
97
-
98
- /**
99
- * Analyze anchor text quality
100
- */
101
- function analyzeAnchorText(text: string): { isGeneric: boolean; isTooLong: boolean; isEmpty: boolean } {
102
- const normalized = text.toLowerCase().trim();
103
-
104
- return {
105
- isEmpty: normalized.length === 0,
106
- isGeneric: GENERIC_ANCHOR_TEXTS.some(g => normalized === g || normalized.includes(g)),
107
- isTooLong: normalized.length > 100,
108
- };
109
- }
110
-
111
- /**
112
- * Analyze internal linking structure
113
- */
114
- export function analyzeInternalLinking(html: string, url: string): InternalLinkingResult {
115
- const $ = cheerio.load(html);
116
- const issues: AuditIssue[] = [];
117
- const recommendations: string[] = [];
118
- let score = 100;
119
-
120
- const linkDetails: LinkInfo[] = [];
121
- const anchorTextCounts: Record<string, number> = {};
122
-
123
- let totalLinks = 0;
124
- let internalLinks = 0;
125
- let externalLinks = 0;
126
- let navigationLinks = 0;
127
- let contentLinks = 0;
128
- let linksWithGenericText = 0;
129
- let linksWithKeywords = 0;
130
- let emptyAnchorLinks = 0;
131
- let tooLongAnchorLinks = 0;
132
- let imageLinks = 0;
133
-
134
- const internalTargets = new Set<string>();
135
-
136
- $('a[href]').each((_, el) => {
137
- const $link = $(el);
138
- const href = $link.attr('href') || '';
139
- const text = $link.text().trim();
140
- const rel = $link.attr('rel');
141
- const title = $link.attr('title');
142
- const hasImage = $link.find('img').length > 0;
143
-
144
- // Skip non-HTTP links
145
- if (href.startsWith('mailto:') || href.startsWith('tel:') || href.startsWith('javascript:')) {
146
- return;
147
- }
148
-
149
- totalLinks++;
150
- const linkIssues: string[] = [];
151
- const isInternal = isInternalUrl(href, url);
152
- const isNav = isNavigationLink($link, $);
153
-
154
- if (isInternal) {
155
- internalLinks++;
156
-
157
- // Track unique targets
158
- try {
159
- const targetUrl = new URL(href, url).pathname;
160
- internalTargets.add(targetUrl);
161
- } catch {}
162
- } else if (href.startsWith('http')) {
163
- externalLinks++;
164
- }
165
-
166
- if (isNav) {
167
- navigationLinks++;
168
- } else {
169
- contentLinks++;
170
- }
171
-
172
- // Analyze anchor text
173
- const anchorAnalysis = analyzeAnchorText(text);
174
-
175
- if (hasImage && !text) {
176
- imageLinks++;
177
- const imgAlt = $link.find('img').attr('alt');
178
- if (!imgAlt) {
179
- linkIssues.push('Image link without alt text');
180
- }
181
- } else if (anchorAnalysis.isEmpty) {
182
- emptyAnchorLinks++;
183
- linkIssues.push('Empty anchor text');
184
- } else if (anchorAnalysis.isGeneric) {
185
- linksWithGenericText++;
186
- linkIssues.push('Generic anchor text');
187
- } else {
188
- linksWithKeywords++;
189
- }
190
-
191
- if (anchorAnalysis.isTooLong) {
192
- tooLongAnchorLinks++;
193
- linkIssues.push('Anchor text too long');
194
- }
195
-
196
- // Track anchor text patterns
197
- if (text) {
198
- const normalizedText = text.toLowerCase().substring(0, 50);
199
- anchorTextCounts[normalizedText] = (anchorTextCounts[normalizedText] || 0) + 1;
200
- }
201
-
202
- // Check for nofollow on internal links
203
- if (isInternal && rel?.includes('nofollow')) {
204
- linkIssues.push('nofollow on internal link');
205
- }
206
-
207
- // Check for sponsored/ugc on internal links
208
- if (isInternal && (rel?.includes('sponsored') || rel?.includes('ugc'))) {
209
- linkIssues.push('sponsored/ugc on internal link');
210
- }
211
-
212
- linkDetails.push({
213
- href: href.substring(0, 200),
214
- text: text.substring(0, 100),
215
- isInternal,
216
- isNavigation: isNav,
217
- rel,
218
- title,
219
- issues: linkIssues,
220
- });
221
- });
222
-
223
- // Generate anchor text patterns
224
- const anchorPatterns = Object.entries(anchorTextCounts)
225
- .sort((a, b) => b[1] - a[1])
226
- .slice(0, 10)
227
- .map(([text, count]) => ({ text, count }));
228
-
229
- // Analyze results
230
- const uniqueInternalTargets = internalTargets.size;
231
-
232
- // Check for orphan risk (very few internal links)
233
- const orphanRisk = internalLinks < 3 && contentLinks < 2;
234
-
235
- // Generate issues
236
- if (internalLinks === 0) {
237
- issues.push({
238
- code: 'LINK_NO_INTERNAL',
239
- severity: 'critical',
240
- category: 'content',
241
- title: 'No internal links found',
242
- description: 'This page has no internal links to other pages on your site.',
243
- impact: 'Poor link equity distribution, crawlability issues',
244
- howToFix: 'Add relevant internal links to other pages on your site.',
245
- affectedUrls: [url],
246
- });
247
- score -= 25;
248
- } else if (contentLinks === 0 && internalLinks < 5) {
249
- issues.push({
250
- code: 'LINK_LOW_INTERNAL',
251
- severity: 'warning',
252
- category: 'content',
253
- title: 'Very few internal links in content',
254
- description: `Only ${internalLinks} internal links found, all in navigation.`,
255
- impact: 'Limited topic relevance signals',
256
- howToFix: 'Add contextual internal links within your content.',
257
- affectedUrls: [url],
258
- });
259
- score -= 15;
260
- }
261
-
262
- if (linksWithGenericText > 3) {
263
- const percentage = Math.round((linksWithGenericText / totalLinks) * 100);
264
- issues.push({
265
- code: 'LINK_GENERIC_ANCHOR',
266
- severity: 'warning',
267
- category: 'content',
268
- title: `${linksWithGenericText} links with generic anchor text`,
269
- description: `${percentage}% of links use non-descriptive text like "click here" or "read more".`,
270
- impact: 'Missed keyword relevance signals',
271
- howToFix: 'Replace generic anchors with descriptive, keyword-rich text.',
272
- affectedUrls: [url],
273
- });
274
- score -= Math.min(linksWithGenericText * 2, 15);
275
- }
276
-
277
- if (emptyAnchorLinks > 0) {
278
- issues.push({
279
- code: 'LINK_EMPTY_ANCHOR',
280
- severity: 'warning',
281
- category: 'content',
282
- title: `${emptyAnchorLinks} links with empty anchor text`,
283
- description: 'Links without text or alt text are inaccessible and provide no SEO value.',
284
- impact: 'Accessibility issues, wasted link equity',
285
- howToFix: 'Add descriptive text or ensure image links have alt text.',
286
- affectedUrls: [url],
287
- });
288
- score -= Math.min(emptyAnchorLinks * 3, 15);
289
- }
290
-
291
- if (orphanRisk) {
292
- issues.push({
293
- code: 'LINK_ORPHAN_RISK',
294
- severity: 'info',
295
- category: 'content',
296
- title: 'Page may be an orphan',
297
- description: 'This page has very few internal links, which may indicate it\'s poorly connected in your site structure.',
298
- impact: 'Difficult for users and crawlers to find',
299
- howToFix: 'Link to this page from related content and relevant hub pages.',
300
- affectedUrls: [url],
301
- });
302
- score -= 10;
303
- }
304
-
305
- // Check internal link nofollow
306
- const nofollowInternalLinks = linkDetails.filter(l => l.isInternal && l.rel?.includes('nofollow'));
307
- if (nofollowInternalLinks.length > 0) {
308
- issues.push({
309
- code: 'LINK_NOFOLLOW_INTERNAL',
310
- severity: 'warning',
311
- category: 'technical',
312
- title: `${nofollowInternalLinks.length} internal links with nofollow`,
313
- description: 'Internal links should not have nofollow - it wastes PageRank.',
314
- impact: 'Reduced internal link equity flow',
315
- howToFix: 'Remove nofollow from internal links.',
316
- affectedUrls: [url],
317
- });
318
- score -= nofollowInternalLinks.length * 3;
319
- }
320
-
321
- // Check for excessive external links
322
- if (externalLinks > internalLinks && externalLinks > 10) {
323
- issues.push({
324
- code: 'LINK_EXTERNAL_HEAVY',
325
- severity: 'info',
326
- category: 'content',
327
- title: 'More external links than internal',
328
- description: `${externalLinks} external vs ${internalLinks} internal links.`,
329
- impact: 'May leak PageRank to external sites',
330
- howToFix: 'Consider adding more internal links or using nofollow/sponsored for some external links.',
331
- affectedUrls: [url],
332
- });
333
- }
334
-
335
- // Recommendations
336
- if (contentLinks < 3 && internalLinks > 0) {
337
- recommendations.push('Add 2-3 contextual internal links within your content');
338
- }
339
-
340
- if (linksWithKeywords / Math.max(totalLinks, 1) > 0.7) {
341
- recommendations.push('✓ Good use of descriptive anchor text');
342
- }
343
-
344
- if (uniqueInternalTargets > 5) {
345
- recommendations.push('✓ Good diversity of internal link targets');
346
- }
347
-
348
- // Suggest hub pages
349
- if (internalLinks > 10) {
350
- recommendations.push('Consider creating a hub/pillar page to consolidate topic authority');
351
- }
352
-
353
- return {
354
- score: Math.max(0, Math.min(100, score)),
355
- totalLinks,
356
- internalLinks,
357
- externalLinks,
358
- navigationLinks,
359
- contentLinks,
360
- uniqueInternalTargets,
361
- linksWithKeywords,
362
- linksWithGenericText,
363
- orphanRisk,
364
- linkDetails,
365
- anchorTextAnalysis: {
366
- total: totalLinks,
367
- descriptive: linksWithKeywords,
368
- generic: linksWithGenericText,
369
- empty: emptyAnchorLinks,
370
- tooLong: tooLongAnchorLinks,
371
- imageLinks,
372
- patterns: anchorPatterns,
373
- },
374
- issues,
375
- recommendations,
376
- };
377
- }
378
-
379
- /**
380
- * Suggest internal linking opportunities
381
- */
382
- export function suggestInternalLinks(content: string, availablePages: { url: string; title: string; keywords: string[] }[]): {
383
- keyword: string;
384
- suggestedUrl: string;
385
- suggestedTitle: string;
386
- relevance: number;
387
- }[] {
388
- const suggestions: { keyword: string; suggestedUrl: string; suggestedTitle: string; relevance: number }[] = [];
389
- const contentLower = content.toLowerCase();
390
-
391
- for (const page of availablePages) {
392
- for (const keyword of page.keywords) {
393
- if (contentLower.includes(keyword.toLowerCase())) {
394
- // Check if not already linked
395
- const alreadyLinked = content.includes(`href="${page.url}"`) ||
396
- content.includes(`href='${page.url}'`);
397
-
398
- if (!alreadyLinked) {
399
- // Simple relevance: keyword length + position
400
- const position = contentLower.indexOf(keyword.toLowerCase());
401
- const relevance = (keyword.length * 2) + (1000 - Math.min(position, 1000)) / 100;
402
-
403
- suggestions.push({
404
- keyword,
405
- suggestedUrl: page.url,
406
- suggestedTitle: page.title,
407
- relevance,
408
- });
409
- }
410
- }
411
- }
412
- }
413
-
414
- // Sort by relevance and dedupe
415
- return suggestions
416
- .sort((a, b) => b.relevance - a.relevance)
417
- .filter((s, i, arr) => arr.findIndex(x => x.suggestedUrl === s.suggestedUrl) === i)
418
- .slice(0, 10);
419
- }
@@ -1,140 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { analyzeMobileSEO } from './mobile-seo-analyzer.js';
3
-
4
- describe('Mobile SEO Analyzer', () => {
5
- describe('analyzeMobileSEO', () => {
6
- it('detects proper viewport', () => {
7
- const html = `
8
- <!DOCTYPE html>
9
- <html>
10
- <head>
11
- <meta name="viewport" content="width=device-width, initial-scale=1">
12
- </head>
13
- <body><h1>Test</h1></body>
14
- </html>
15
- `;
16
- const result = analyzeMobileSEO(html, 'https://example.com');
17
- expect(result.viewport.hasViewport).toBe(true);
18
- expect(result.viewport.isResponsive).toBe(true);
19
- });
20
-
21
- it('detects missing viewport', () => {
22
- const html = `
23
- <!DOCTYPE html>
24
- <html>
25
- <head><title>Test</title></head>
26
- <body><h1>Test</h1></body>
27
- </html>
28
- `;
29
- const result = analyzeMobileSEO(html, 'https://example.com');
30
- expect(result.viewport.hasViewport).toBe(false);
31
- expect(result.issues.some(i => i.code === 'MOBILE_NO_VIEWPORT')).toBe(true);
32
- });
33
-
34
- it('detects fixed viewport width', () => {
35
- const html = `
36
- <!DOCTYPE html>
37
- <html>
38
- <head>
39
- <meta name="viewport" content="width=1024">
40
- </head>
41
- <body><h1>Test</h1></body>
42
- </html>
43
- `;
44
- const result = analyzeMobileSEO(html, 'https://example.com');
45
- expect(result.viewport.isResponsive).toBe(false);
46
- });
47
-
48
- it('warns about disabled zooming', () => {
49
- const html = `
50
- <!DOCTYPE html>
51
- <html>
52
- <head>
53
- <meta name="viewport" content="width=device-width, user-scalable=no">
54
- </head>
55
- <body><h1>Test</h1></body>
56
- </html>
57
- `;
58
- const result = analyzeMobileSEO(html, 'https://example.com');
59
- expect(result.issues.some(i => i.code === 'MOBILE_ZOOM_DISABLED')).toBe(true);
60
- });
61
-
62
- it('detects apple touch icon', () => {
63
- const html = `
64
- <!DOCTYPE html>
65
- <html>
66
- <head>
67
- <meta name="viewport" content="width=device-width, initial-scale=1">
68
- <link rel="apple-touch-icon" href="/apple-touch-icon.png">
69
- </head>
70
- <body><h1>Test</h1></body>
71
- </html>
72
- `;
73
- const result = analyzeMobileSEO(html, 'https://example.com');
74
- expect(result.mobileSpecific.hasAppleTouchIcon).toBe(true);
75
- });
76
-
77
- it('detects theme color', () => {
78
- const html = `
79
- <!DOCTYPE html>
80
- <html>
81
- <head>
82
- <meta name="viewport" content="width=device-width, initial-scale=1">
83
- <meta name="theme-color" content="#ffffff">
84
- </head>
85
- <body><h1>Test</h1></body>
86
- </html>
87
- `;
88
- const result = analyzeMobileSEO(html, 'https://example.com');
89
- expect(result.mobileSpecific.hasThemeColor).toBe(true);
90
- });
91
-
92
- it('detects web app manifest', () => {
93
- const html = `
94
- <!DOCTYPE html>
95
- <html>
96
- <head>
97
- <meta name="viewport" content="width=device-width, initial-scale=1">
98
- <link rel="manifest" href="/manifest.json">
99
- </head>
100
- <body><h1>Test</h1></body>
101
- </html>
102
- `;
103
- const result = analyzeMobileSEO(html, 'https://example.com');
104
- expect(result.mobileSpecific.hasManifest).toBe(true);
105
- });
106
-
107
- it('detects responsive images', () => {
108
- const html = `
109
- <!DOCTYPE html>
110
- <html>
111
- <head>
112
- <meta name="viewport" content="width=device-width, initial-scale=1">
113
- </head>
114
- <body>
115
- <img srcset="/image-400.jpg 400w, /image-800.jpg 800w" src="/image.jpg" alt="Test">
116
- </body>
117
- </html>
118
- `;
119
- const result = analyzeMobileSEO(html, 'https://example.com');
120
- expect(result.mobileSpecific.hasMobileOptimizedImages).toBe(true);
121
- });
122
-
123
- it('calculates overall score', () => {
124
- const html = `
125
- <!DOCTYPE html>
126
- <html>
127
- <head>
128
- <meta name="viewport" content="width=device-width, initial-scale=1">
129
- <meta name="theme-color" content="#000000">
130
- <link rel="manifest" href="/manifest.json">
131
- <link rel="apple-touch-icon" href="/icon.png">
132
- </head>
133
- <body><h1>Test</h1></body>
134
- </html>
135
- `;
136
- const result = analyzeMobileSEO(html, 'https://example.com');
137
- expect(result.score).toBeGreaterThan(80);
138
- });
139
- });
140
- });