vite-plugin-sitemap-ts 1.4.1 → 1.4.3
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 +23 -0
- package/dist/index.cjs +0 -2
- package/dist/index.d.cts +0 -6
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -150,6 +150,29 @@ sitemap({
|
|
|
150
150
|
</urlset>
|
|
151
151
|
```
|
|
152
152
|
|
|
153
|
+
### With dynamic routes:
|
|
154
|
+
|
|
155
|
+
Since the Vite config supports async, you can fetch routes dynamically and pass them to the plugin.
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
// vite.config.ts
|
|
159
|
+
import { defineConfig } from 'vite'
|
|
160
|
+
import { sitemap } from 'vite-plugin-sitemap-ts'
|
|
161
|
+
|
|
162
|
+
export default defineConfig(async () => {
|
|
163
|
+
const routes = await fetchRoutesFromCMS()
|
|
164
|
+
|
|
165
|
+
return {
|
|
166
|
+
plugins: [
|
|
167
|
+
sitemap({
|
|
168
|
+
hostname: 'https://example.com',
|
|
169
|
+
routes,
|
|
170
|
+
}),
|
|
171
|
+
],
|
|
172
|
+
}
|
|
173
|
+
})
|
|
174
|
+
```
|
|
175
|
+
|
|
153
176
|
## Options
|
|
154
177
|
|
|
155
178
|
The `hostname` option is required. All other options are optional.
|
package/dist/index.cjs
CHANGED
|
@@ -135,7 +135,6 @@ var FILE_NAME = "sitemap.xml";
|
|
|
135
135
|
var SITEMAP_PATH = `${BASE_PATH}${FILE_NAME}`;
|
|
136
136
|
function sitemap(options) {
|
|
137
137
|
let config;
|
|
138
|
-
const enabled = options.enabled ?? true;
|
|
139
138
|
const host = options.hostname ?? void 0;
|
|
140
139
|
const routes = options.routes?.length ? options.routes : ["/"];
|
|
141
140
|
const customOutDir = options.outDir ?? void 0;
|
|
@@ -144,7 +143,6 @@ function sitemap(options) {
|
|
|
144
143
|
}
|
|
145
144
|
return {
|
|
146
145
|
name: "vite-plugin-sitemap-ts",
|
|
147
|
-
apply: () => enabled,
|
|
148
146
|
configResolved(resolvedConfig) {
|
|
149
147
|
config = resolvedConfig;
|
|
150
148
|
},
|
package/dist/index.d.cts
CHANGED
|
@@ -13,12 +13,6 @@ type SitemapEntry = {
|
|
|
13
13
|
hreflang?: HrefLangEntry[];
|
|
14
14
|
};
|
|
15
15
|
type Options = {
|
|
16
|
-
/**
|
|
17
|
-
* Toggle the plugin on or off. Useful if you want to disable the plugin, e.g. in development mode.
|
|
18
|
-
*
|
|
19
|
-
* **Default: `true`**
|
|
20
|
-
*/
|
|
21
|
-
enabled?: boolean;
|
|
22
16
|
/**
|
|
23
17
|
* The hostname of the site, used to build the full URLs in the sitemap.
|
|
24
18
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -13,12 +13,6 @@ type SitemapEntry = {
|
|
|
13
13
|
hreflang?: HrefLangEntry[];
|
|
14
14
|
};
|
|
15
15
|
type Options = {
|
|
16
|
-
/**
|
|
17
|
-
* Toggle the plugin on or off. Useful if you want to disable the plugin, e.g. in development mode.
|
|
18
|
-
*
|
|
19
|
-
* **Default: `true`**
|
|
20
|
-
*/
|
|
21
|
-
enabled?: boolean;
|
|
22
16
|
/**
|
|
23
17
|
* The hostname of the site, used to build the full URLs in the sitemap.
|
|
24
18
|
*
|
package/dist/index.js
CHANGED
|
@@ -109,7 +109,6 @@ var FILE_NAME = "sitemap.xml";
|
|
|
109
109
|
var SITEMAP_PATH = `${BASE_PATH}${FILE_NAME}`;
|
|
110
110
|
function sitemap(options) {
|
|
111
111
|
let config;
|
|
112
|
-
const enabled = options.enabled ?? true;
|
|
113
112
|
const host = options.hostname ?? void 0;
|
|
114
113
|
const routes = options.routes?.length ? options.routes : ["/"];
|
|
115
114
|
const customOutDir = options.outDir ?? void 0;
|
|
@@ -118,7 +117,6 @@ function sitemap(options) {
|
|
|
118
117
|
}
|
|
119
118
|
return {
|
|
120
119
|
name: "vite-plugin-sitemap-ts",
|
|
121
|
-
apply: () => enabled,
|
|
122
120
|
configResolved(resolvedConfig) {
|
|
123
121
|
config = resolvedConfig;
|
|
124
122
|
},
|
package/package.json
CHANGED