vite-plugin-sitemap-ts 1.3.0 → 1.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/README.md CHANGED
@@ -48,7 +48,7 @@ sitemap({
48
48
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
49
49
  <url>
50
50
  <loc>https://example.com/</loc>
51
- <lastmod>2026-03-14T19:27:44.429Z</lastmod>
51
+ <lastmod>2026-03-14</lastmod>
52
52
  </url>
53
53
  </urlset>
54
54
  ```
@@ -70,7 +70,7 @@ sitemap({
70
70
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
71
71
  <url>
72
72
  <loc>https://example.com/about</loc>
73
- <lastmod>2026-03-14T19:42:17.729Z</lastmod>
73
+ <lastmod>2026-03-14</lastmod>
74
74
  </url>
75
75
  </urlset>
76
76
  ```
@@ -101,11 +101,11 @@ sitemap({
101
101
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
102
102
  <url>
103
103
  <loc>https://example.com/</loc>
104
- <lastmod>2026-03-14T20:31:12.450Z</lastmod>
104
+ <lastmod>2026-03-14</lastmod>
105
105
  </url>
106
106
  <url>
107
107
  <loc>https://example.com/about</loc>
108
- <lastmod>2026-03-14T20:31:12.450Z</lastmod>
108
+ <lastmod>2026-03-14</lastmod>
109
109
  </url>
110
110
  <url>
111
111
  <loc>https://example.com/blog</loc>
@@ -127,9 +127,9 @@ sitemap({
127
127
  {
128
128
  loc: '/about',
129
129
  hreflang: [
130
- { lang: 'en', href: 'https://example.com/about' },
131
- { lang: 'de', href: 'https://example.com/de/ueber' },
132
- { lang: 'x-default', href: 'https://example.com/about' },
130
+ { lang: 'en', loc: '/about' },
131
+ { lang: 'de', loc: '/de/ueber' },
132
+ { lang: 'x-default', loc: '/about' },
133
133
  ],
134
134
  },
135
135
  ],
@@ -142,7 +142,7 @@ sitemap({
142
142
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
143
143
  <url>
144
144
  <loc>https://example.com/about</loc>
145
- <lastmod>2026-03-14T21:02:53.166Z</lastmod>
145
+ <lastmod>2026-03-14</lastmod>
146
146
  <xhtml:link rel="alternate" hreflang="en" href="https://example.com/about" />
147
147
  <xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/ueber" />
148
148
  <xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/about" />
package/dist/index.cjs CHANGED
@@ -85,7 +85,7 @@ ${DSPACER}<priority>${escapeXml(entry.priority)}</priority>`;
85
85
  hasHreflang = true;
86
86
  entry.hreflang.forEach((alt) => {
87
87
  sitemapEntry += `
88
- ${DSPACER}<xhtml:link rel="alternate" hreflang="${escapeXml(alt.lang)}" href="${escapeXml(alt.href)}" />`;
88
+ ${DSPACER}<xhtml:link rel="alternate" hreflang="${escapeXml(alt.lang)}" href="${escapeXml(alt.loc)}" />`;
89
89
  });
90
90
  }
91
91
  return `${SPACER}<url>
@@ -97,7 +97,7 @@ ${xmlSchema(urls, hasHreflang)}`;
97
97
  };
98
98
  var buildSitemapEntries = (options) => {
99
99
  const host = options.hostname.replace(/\/$/, "");
100
- const lastmod = (/* @__PURE__ */ new Date()).toISOString();
100
+ const lastmod = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
101
101
  return options.routes.map((route) => {
102
102
  if (typeof route === "string") {
103
103
  return {
@@ -108,7 +108,11 @@ var buildSitemapEntries = (options) => {
108
108
  return {
109
109
  ...route,
110
110
  loc: `${host}/${route.loc.replace(/^\/+/, "")}`,
111
- lastmod: route.lastmod ?? lastmod
111
+ lastmod: route.lastmod ?? lastmod,
112
+ hreflang: route.hreflang?.map((alt) => ({
113
+ ...alt,
114
+ loc: `${host}/${alt.loc.replace(/^\/+/, "")}`
115
+ }))
112
116
  };
113
117
  });
114
118
  };
package/dist/index.d.cts CHANGED
@@ -3,7 +3,7 @@ import { Plugin } from 'vite';
3
3
  type ChangeFreq = 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
4
4
  type HrefLangEntry = {
5
5
  lang: string;
6
- href: string;
6
+ loc: string;
7
7
  };
8
8
  type SitemapEntry = {
9
9
  loc: string;
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { Plugin } from 'vite';
3
3
  type ChangeFreq = 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
4
4
  type HrefLangEntry = {
5
5
  lang: string;
6
- href: string;
6
+ loc: string;
7
7
  };
8
8
  type SitemapEntry = {
9
9
  loc: string;
package/dist/index.js CHANGED
@@ -49,7 +49,7 @@ ${DSPACER}<priority>${escapeXml(entry.priority)}</priority>`;
49
49
  hasHreflang = true;
50
50
  entry.hreflang.forEach((alt) => {
51
51
  sitemapEntry += `
52
- ${DSPACER}<xhtml:link rel="alternate" hreflang="${escapeXml(alt.lang)}" href="${escapeXml(alt.href)}" />`;
52
+ ${DSPACER}<xhtml:link rel="alternate" hreflang="${escapeXml(alt.lang)}" href="${escapeXml(alt.loc)}" />`;
53
53
  });
54
54
  }
55
55
  return `${SPACER}<url>
@@ -61,7 +61,7 @@ ${xmlSchema(urls, hasHreflang)}`;
61
61
  };
62
62
  var buildSitemapEntries = (options) => {
63
63
  const host = options.hostname.replace(/\/$/, "");
64
- const lastmod = (/* @__PURE__ */ new Date()).toISOString();
64
+ const lastmod = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
65
65
  return options.routes.map((route) => {
66
66
  if (typeof route === "string") {
67
67
  return {
@@ -72,7 +72,11 @@ var buildSitemapEntries = (options) => {
72
72
  return {
73
73
  ...route,
74
74
  loc: `${host}/${route.loc.replace(/^\/+/, "")}`,
75
- lastmod: route.lastmod ?? lastmod
75
+ lastmod: route.lastmod ?? lastmod,
76
+ hreflang: route.hreflang?.map((alt) => ({
77
+ ...alt,
78
+ loc: `${host}/${alt.loc.replace(/^\/+/, "")}`
79
+ }))
76
80
  };
77
81
  });
78
82
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-sitemap-ts",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Vite plugin to generate sitemap.xml. Works in dev mode.",
5
5
  "author": "Cornelius Weidmann <cornelius@kyco.io> (https://kyco.io)",
6
6
  "license": "MIT",