easy-sitemap-generator 0.1.0 → 0.1.1
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/lib/sitemapGenerator.js +5 -9
- package/package.json +2 -2
package/lib/sitemapGenerator.js
CHANGED
|
@@ -16,7 +16,6 @@ const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
|
16
16
|
const fetchUrl = async (url, retries = 0) => {
|
|
17
17
|
try {
|
|
18
18
|
logInfo(`GET ${url}`);
|
|
19
|
-
|
|
20
19
|
return await axios.get(url);
|
|
21
20
|
} catch (err) {
|
|
22
21
|
logError(`Error fetching URL: ${url} - ${err.message}`);
|
|
@@ -45,13 +44,10 @@ const crawl = async (url, baseUrl) => {
|
|
|
45
44
|
const normalizedUrl = normalizeUrl(url);
|
|
46
45
|
if (VISITED_URLS.has(normalizedUrl)) return; else VISITED_URLS.add(normalizedUrl);
|
|
47
46
|
|
|
48
|
-
const
|
|
49
|
-
if (!
|
|
50
|
-
logWarning(`No response received for URL: ${normalizedUrl}`);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
47
|
+
const res = await fetchUrl(normalizedUrl);
|
|
48
|
+
if (!res) return logWarning(`No response received for URL: ${normalizedUrl}`);
|
|
53
49
|
|
|
54
|
-
const { document } = new JSDOM(
|
|
50
|
+
const { document } = new JSDOM(res.data).window;
|
|
55
51
|
const links = Array.from(document.querySelectorAll('a[href]'))
|
|
56
52
|
.map(link => urlModule.resolve(baseUrl, link.getAttribute('href')))
|
|
57
53
|
.map(normalizeUrl)
|
|
@@ -63,7 +59,7 @@ const crawl = async (url, baseUrl) => {
|
|
|
63
59
|
await crawl(link, baseUrl);
|
|
64
60
|
}
|
|
65
61
|
|
|
66
|
-
return { url: normalizedUrl, lastmod:
|
|
62
|
+
return { url: normalizedUrl, lastmod: res.headers['last-modified'] ? new Date(res.headers['last-modified']).toISOString() : new Date().toISOString() };
|
|
67
63
|
};
|
|
68
64
|
|
|
69
65
|
const generateSitemap = async (baseUrl, destination = 'sitemap.xml') => {
|
|
@@ -83,7 +79,7 @@ const generateSitemap = async (baseUrl, destination = 'sitemap.xml') => {
|
|
|
83
79
|
.sort((a, b) => b.priority - a.priority);
|
|
84
80
|
|
|
85
81
|
const sitemapContent = `<?xml version="1.0" encoding="UTF-8"?>
|
|
86
|
-
<!-- Generated by sitemap
|
|
82
|
+
<!-- Generated by https://github.com/sefinek24/easy-sitemap-generator - ${new Date()} -->
|
|
87
83
|
<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">
|
|
88
84
|
${urls.map(({ url, priority, lastmod }) => ` <url>
|
|
89
85
|
<loc>${escapeXml(url)}</loc>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "easy-sitemap-generator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
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": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"up": "ncu -u && npm install && npm update && npm audit fix"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"axios": "^1.7.
|
|
28
|
+
"axios": "^1.7.4",
|
|
29
29
|
"jsdom": "^24.1.1",
|
|
30
30
|
"kleur": "^4.1.5"
|
|
31
31
|
},
|