vite-plugin-sitemap 0.7.0 → 0.8.0

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
@@ -30,7 +30,7 @@ import Sitemap from 'vite-plugin-sitemap'
30
30
  export default {
31
31
  plugins: [
32
32
  Vue(),
33
- Sitemap(),
33
+ Sitemap({ hostname: 'https://example.com' }),
34
34
  ],
35
35
  }
36
36
  ```
@@ -175,6 +175,15 @@ strategy specifies if the language code is a suffix to the path or a prefix. 'su
175
175
 
176
176
  Enables robots.txt file generation
177
177
 
178
+ ### xmlns
179
+
180
+ - **Type:** `NSArgs`
181
+ - **Default:** `undefined`
182
+
183
+ Trim the xml namespace
184
+ See https://www.npmjs.com/package/sitemap#options-you-can-pass
185
+ Type: https://github.com/ekalinin/sitemap.js/blob/0af656e6a4a7b1403c9b3af23603261bd9cf94d3/lib/sitemap-stream.ts#L20
186
+
178
187
  ### robots
179
188
 
180
189
  - **Type:** `RobotOption[]`
package/dist/index.d.ts CHANGED
@@ -54,12 +54,14 @@ interface Options {
54
54
  * Example: {
55
55
  * defaultLanguage: 'fr'
56
56
  * languages: ['fr', 'en', 'es']
57
+ * strategy: 'suffix' | 'prefix'
57
58
  * }
58
- * @default undefined
59
+ * @default undefined, strategy: 'suffix'
59
60
  */
60
61
  i18n?: {
61
62
  defaultLanguage?: string;
62
63
  languages: string[];
64
+ strategy?: 'suffix' | 'prefix';
63
65
  };
64
66
  /**
65
67
  * Other sitemaps paths
package/dist/index.js CHANGED
@@ -10998,6 +10998,8 @@ function assertPatternsInput(input) {
10998
10998
  }
10999
10999
  var out = FastGlob;
11000
11000
 
11001
+ var fg = /*@__PURE__*/getDefaultExportFromCjs(out);
11002
+
11001
11003
  const defaultOptions = {
11002
11004
  hostname: "http://localhost/",
11003
11005
  dynamicRoutes: [],
@@ -11073,7 +11075,7 @@ function getRoutes(options) {
11073
11075
  const ext = typeof options.extensions === "string" ? [options.extensions] : options.extensions;
11074
11076
  const strExt = ext.map((e) => `**/*.${e}`);
11075
11077
  return [
11076
- ...out.sync(strExt, { cwd: options.outDir }).map((route) => {
11078
+ ...fg.sync(strExt, { cwd: options.outDir }).map((route) => {
11077
11079
  let r = route;
11078
11080
  ext.forEach((e) => {
11079
11081
  const regex = new RegExp(`index.${e}`, "g");
@@ -11097,7 +11099,9 @@ function getOptionByRoute(options, route) {
11097
11099
  }
11098
11100
  function getFormattedSitemap(options, routes) {
11099
11101
  return routes.map((route) => {
11100
- const url = new URL(options.basePath ? ensurePrefix("/", options.basePath) + ensurePrefix("/", route) : ensurePrefix("/", route), removeMaybeSuffix("/", options.hostname)).href;
11102
+ const hostNamePath = removeMaybeSuffix("/", options.hostname);
11103
+ const routePath = options.basePath ? ensurePrefix("/", options.basePath) + ensurePrefix("/", route) : ensurePrefix("/", route);
11104
+ const url = new URL(routePath, hostNamePath).href;
11101
11105
  const formattedSitemap = {
11102
11106
  url,
11103
11107
  changefreq: getOptionByRoute(options.changefreq, route) ?? defaultOptions.changefreq,
@@ -11105,9 +11109,10 @@ function getFormattedSitemap(options, routes) {
11105
11109
  lastmod: getOptionByRoute(options.lastmod, route) ?? defaultOptions.lastmod
11106
11110
  };
11107
11111
  if (options.i18n) {
11112
+ const strategy = options.i18n.strategy ?? "suffix";
11108
11113
  const languages = options.i18n.languages.map((str) => ({
11109
11114
  lang: str,
11110
- url: str === options.i18n?.defaultLanguage ? url : `${removeMaybeSuffix("/", url)}${ensurePrefix("/", str)}`
11115
+ url: str === options.i18n?.defaultLanguage ? url : new URL(strategy === "prefix" ? ensurePrefix("/", str) + routePath : removeMaybeSuffix("/", routePath) + ensurePrefix("/", str), hostNamePath).href
11111
11116
  }));
11112
11117
  return Object.assign(formattedSitemap, { links: options.i18n.defaultLanguage ? [...languages, { lang: "x-default", url }] : languages });
11113
11118
  }
package/dist/index.mjs CHANGED
@@ -10998,6 +10998,8 @@ function assertPatternsInput(input) {
10998
10998
  }
10999
10999
  var out = FastGlob;
11000
11000
 
11001
+ var fg = /*@__PURE__*/getDefaultExportFromCjs(out);
11002
+
11001
11003
  const defaultOptions = {
11002
11004
  hostname: "http://localhost/",
11003
11005
  dynamicRoutes: [],
@@ -11073,7 +11075,7 @@ function getRoutes(options) {
11073
11075
  const ext = typeof options.extensions === "string" ? [options.extensions] : options.extensions;
11074
11076
  const strExt = ext.map((e) => `**/*.${e}`);
11075
11077
  return [
11076
- ...out.sync(strExt, { cwd: options.outDir }).map((route) => {
11078
+ ...fg.sync(strExt, { cwd: options.outDir }).map((route) => {
11077
11079
  let r = route;
11078
11080
  ext.forEach((e) => {
11079
11081
  const regex = new RegExp(`index.${e}`, "g");
@@ -11097,7 +11099,9 @@ function getOptionByRoute(options, route) {
11097
11099
  }
11098
11100
  function getFormattedSitemap(options, routes) {
11099
11101
  return routes.map((route) => {
11100
- const url = new URL(options.basePath ? ensurePrefix("/", options.basePath) + ensurePrefix("/", route) : ensurePrefix("/", route), removeMaybeSuffix("/", options.hostname)).href;
11102
+ const hostNamePath = removeMaybeSuffix("/", options.hostname);
11103
+ const routePath = options.basePath ? ensurePrefix("/", options.basePath) + ensurePrefix("/", route) : ensurePrefix("/", route);
11104
+ const url = new URL(routePath, hostNamePath).href;
11101
11105
  const formattedSitemap = {
11102
11106
  url,
11103
11107
  changefreq: getOptionByRoute(options.changefreq, route) ?? defaultOptions.changefreq,
@@ -11105,9 +11109,10 @@ function getFormattedSitemap(options, routes) {
11105
11109
  lastmod: getOptionByRoute(options.lastmod, route) ?? defaultOptions.lastmod
11106
11110
  };
11107
11111
  if (options.i18n) {
11112
+ const strategy = options.i18n.strategy ?? "suffix";
11108
11113
  const languages = options.i18n.languages.map((str) => ({
11109
11114
  lang: str,
11110
- url: str === options.i18n?.defaultLanguage ? url : `${removeMaybeSuffix("/", url)}${ensurePrefix("/", str)}`
11115
+ url: str === options.i18n?.defaultLanguage ? url : new URL(strategy === "prefix" ? ensurePrefix("/", str) + routePath : removeMaybeSuffix("/", routePath) + ensurePrefix("/", str), hostNamePath).href
11111
11116
  }));
11112
11117
  return Object.assign(formattedSitemap, { links: options.i18n.defaultLanguage ? [...languages, { lang: "x-default", url }] : languages });
11113
11118
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vite-plugin-sitemap",
3
3
  "type": "module",
4
- "version": "0.7.0",
4
+ "version": "0.8.0",
5
5
  "packageManager": "pnpm@9.1.2",
6
6
  "description": "Sitemap generator plugin for Vite",
7
7
  "main": "dist/index.js",
@@ -27,7 +27,7 @@
27
27
  "eslint-plugin-format": "^0.1.1",
28
28
  "pkgroll": "^2.1.1",
29
29
  "pnpm": "^9.1.2",
30
- "sitemap-ts": "^1.8.0",
30
+ "sitemap-ts": "^1.9.0",
31
31
  "taze": "^0.13.8",
32
32
  "typescript": "^5.4.5",
33
33
  "vite": "^5.2.11",