aeorank 2.3.1 → 2.3.2

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/cli.js CHANGED
@@ -183,16 +183,20 @@ async function prefetchSiteData(domain) {
183
183
  }
184
184
  }
185
185
  }
186
- let blogSample = [];
187
- if (sitemapXml && sitemapXml.status === 200) {
188
- let sitemapForBlog = sitemapXml.text;
189
- const subSitemapUrl = extractSubSitemapUrl(sitemapForBlog);
190
- if (subSitemapUrl) {
191
- const subSitemap = await fetchText(subSitemapUrl);
192
- if (subSitemap && subSitemap.status === 200) {
193
- sitemapForBlog = subSitemap.text;
186
+ if (sitemapXml && sitemapXml.status === 200 && sitemapXml.text.includes("<sitemapindex")) {
187
+ const subUrls = extractAllSubSitemapUrls(sitemapXml.text, 5);
188
+ if (subUrls.length > 0) {
189
+ const subResults = await Promise.all(subUrls.map((u) => fetchText(u)));
190
+ for (const sub of subResults) {
191
+ if (sub && sub.status === 200) {
192
+ sitemapXml.text += "\n" + sub.text;
193
+ }
194
194
  }
195
195
  }
196
+ }
197
+ let blogSample = [];
198
+ if (sitemapXml && sitemapXml.status === 200) {
199
+ const sitemapForBlog = sitemapXml.text;
196
200
  const blogUrls = extractBlogUrlsFromSitemap(sitemapForBlog, domain, 50);
197
201
  if (blogUrls.length > 0) {
198
202
  const fetched = await Promise.all(blogUrls.map((url) => fetchText(url)));
@@ -1237,16 +1241,16 @@ function extractBlogUrlsFromSitemap(sitemapText, domain, limit = 50) {
1237
1241
  });
1238
1242
  return candidates.slice(0, limit).map((c) => c.url);
1239
1243
  }
1240
- function extractSubSitemapUrl(sitemapText) {
1241
- if (!sitemapText.includes("<sitemapindex")) return null;
1244
+ function extractAllSubSitemapUrls(sitemapText, limit = 5) {
1245
+ if (!sitemapText.includes("<sitemapindex")) return [];
1242
1246
  const sitemapLocs = sitemapText.match(/<sitemap>[\s\S]*?<loc>([^<]+)<\/loc>[\s\S]*?<\/sitemap>/gi) || [];
1243
- if (sitemapLocs.length === 0) return null;
1244
1247
  const urls = sitemapLocs.map((block) => {
1245
1248
  const match = block.match(/<loc>([^<]+)<\/loc>/i);
1246
1249
  return match ? match[1].trim() : "";
1247
1250
  }).filter(Boolean);
1248
- const preferred = urls.find((u) => /post|blog|article/i.test(u));
1249
- return preferred || urls[0] || null;
1251
+ const preferred = urls.filter((u) => /post|blog|article|page/i.test(u));
1252
+ const rest = urls.filter((u) => !preferred.includes(u));
1253
+ return [...preferred, ...rest].slice(0, limit);
1250
1254
  }
1251
1255
  function checkContentVelocity(data) {
1252
1256
  const findings = [];