easy-sitemap-generator 0.1.1 → 0.1.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.
@@ -6,7 +6,7 @@ const path = require('path');
6
6
  const { escapeXml, normalizeUrl, calculatePriority } = require('../utils/xml.js');
7
7
  const { logInfo, logSuccess, logError, logWarning } = require('../utils/kleur.js');
8
8
 
9
- const VISITED_URLS = new Set();
9
+ const VISITED_URLS = new Map();
10
10
  const IGNORED_PATTERNS = ['cdn-cgi', '?referrer=', '&referrer=', '/signin/v2/usernamerecovery', '/lifecycle/flows/signup', 'join?return_to='];
11
11
  const BASE_DELAY = 8000;
12
12
 
@@ -42,7 +42,8 @@ const fetchUrl = async (url, retries = 0) => {
42
42
 
43
43
  const crawl = async (url, baseUrl) => {
44
44
  const normalizedUrl = normalizeUrl(url);
45
- if (VISITED_URLS.has(normalizedUrl)) return; else VISITED_URLS.add(normalizedUrl);
45
+ if (VISITED_URLS.has(normalizedUrl)) return;
46
+ VISITED_URLS.set(normalizedUrl, { url: normalizedUrl });
46
47
 
47
48
  const res = await fetchUrl(normalizedUrl);
48
49
  if (!res) return logWarning(`No response received for URL: ${normalizedUrl}`);
@@ -59,7 +60,11 @@ const crawl = async (url, baseUrl) => {
59
60
  await crawl(link, baseUrl);
60
61
  }
61
62
 
62
- return { url: normalizedUrl, lastmod: res.headers['last-modified'] ? new Date(res.headers['last-modified']).toISOString() : new Date().toISOString() };
63
+ VISITED_URLS.set(normalizedUrl, {
64
+ url: normalizedUrl,
65
+ lastmod: (res.headers['last-modified'] ? new Date(res.headers['last-modified']) : new Date()).toISOString(),
66
+ priority: calculatePriority(normalizedUrl, baseUrl)
67
+ });
63
68
  };
64
69
 
65
70
  const generateSitemap = async (baseUrl, destination = 'sitemap.xml') => {
@@ -69,17 +74,11 @@ const generateSitemap = async (baseUrl, destination = 'sitemap.xml') => {
69
74
 
70
75
  logInfo(`Generating sitemap with ${VISITED_URLS.size} URLs...`);
71
76
 
72
- const urls = Array.from(VISITED_URLS)
73
- .filter(url => shouldIncludeUrl(url, baseUrl))
74
- .map(url => ({
75
- url,
76
- priority: calculatePriority(url, baseUrl),
77
- lastmod: new Date().toISOString()
78
- }))
77
+ const urls = Array.from(VISITED_URLS.values())
79
78
  .sort((a, b) => b.priority - a.priority);
80
79
 
81
80
  const sitemapContent = `<?xml version="1.0" encoding="UTF-8"?>
82
- <!-- Generated by https://github.com/sefinek24/easy-sitemap-generator - ${new Date()} -->
81
+ <!-- Generated by https://github.com/sefinek24/easy-sitemap-generator at ${new Date().toISOString()} -->
83
82
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
84
83
  ${urls.map(({ url, priority, lastmod }) => ` <url>
85
84
  <loc>${escapeXml(url)}</loc>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easy-sitemap-generator",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Free and easy sitemap.xml file generator without any restrictions for your website. Try now!",
5
5
  "homepage": "https://github.com/sefinek24/easy-sitemap-generator#readme",
6
6
  "bugs": {
@@ -21,7 +21,7 @@
21
21
  "sitemap-generator": "./bin/cli.js"
22
22
  },
23
23
  "scripts": {
24
- "test": "jest test/index.test.js",
24
+ "test": "echo \"Error: no test specified\" && exit 1",
25
25
  "up": "ncu -u && npm install && npm update && npm audit fix"
26
26
  },
27
27
  "dependencies": {