vite-plugin-sitemap 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/LICENSE +21 -0
- package/README.md +119 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.js +3870 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3872 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 jbaubree
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# vite-plugin-sitemap
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/vite-plugin-sitemap)
|
|
4
|
+
[](https://www.npmjs.com/package/vite-plugin-sitemap)
|
|
5
|
+
[](https://github.com/jbaubree/vite-plugin-sitemap/blob/main/src/types.ts)
|
|
6
|
+
[](https://github.com/jbaubree/vite-plugin-sitemap/blob/main/LICENSE)
|
|
7
|
+
[](https://github.com/jbaubree/vite-plugin-sitemap/actions/workflows/ci.yml)
|
|
8
|
+
|
|
9
|
+
> Sitemap generator plugin for Vite
|
|
10
|
+
|
|
11
|
+
## Getting Started
|
|
12
|
+
|
|
13
|
+
### Vue
|
|
14
|
+
|
|
15
|
+
Install:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install -D vite-plugin-sitemap
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Vite config
|
|
22
|
+
|
|
23
|
+
Add to your `vite.config.js`:
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
import Sitemap from 'vite-plugin-sitemap'
|
|
27
|
+
|
|
28
|
+
export default {
|
|
29
|
+
plugins: [
|
|
30
|
+
Vue(),
|
|
31
|
+
Sitemap(),
|
|
32
|
+
],
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Now, run `npm build` and this will generate sitemap.xml and robots.txt files on your dist folder.
|
|
37
|
+
|
|
38
|
+
### hostname
|
|
39
|
+
|
|
40
|
+
- **Type:** `string`
|
|
41
|
+
- **Default:** `'http://localhost/'`
|
|
42
|
+
|
|
43
|
+
Base URI.
|
|
44
|
+
|
|
45
|
+
### dynamicRoutes
|
|
46
|
+
|
|
47
|
+
- **Type:** `string[]`
|
|
48
|
+
- **Default:** `[]`
|
|
49
|
+
|
|
50
|
+
Array of strings with manual dynamic routes.
|
|
51
|
+
```js
|
|
52
|
+
const names = [
|
|
53
|
+
'John',
|
|
54
|
+
'Bryce',
|
|
55
|
+
'Addison',
|
|
56
|
+
'Dana',
|
|
57
|
+
]
|
|
58
|
+
const dynamicRoutes = names.map(name => `/names/${name}`)
|
|
59
|
+
|
|
60
|
+
export default {
|
|
61
|
+
plugins: [
|
|
62
|
+
Vue(),
|
|
63
|
+
Sitemap({ dynamicRoutes }),
|
|
64
|
+
],
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
You can find a working example in example folder.
|
|
69
|
+
|
|
70
|
+
### outDir
|
|
71
|
+
|
|
72
|
+
- **Type:** `string`
|
|
73
|
+
- **Default:** `'dist'`
|
|
74
|
+
|
|
75
|
+
Output directory.
|
|
76
|
+
|
|
77
|
+
### changefreq
|
|
78
|
+
|
|
79
|
+
- **Type:** `string`
|
|
80
|
+
- **Default:** `'daily'`
|
|
81
|
+
|
|
82
|
+
Change frequency option for sitemap.
|
|
83
|
+
|
|
84
|
+
### priority
|
|
85
|
+
|
|
86
|
+
- **Type:** `number`
|
|
87
|
+
- **Default:** `1`
|
|
88
|
+
|
|
89
|
+
Priority option for sitemap.
|
|
90
|
+
|
|
91
|
+
### lastmod
|
|
92
|
+
|
|
93
|
+
- **Type:** `Date`
|
|
94
|
+
- **Default:** `new Date()`
|
|
95
|
+
|
|
96
|
+
Last modification option for sitemap.
|
|
97
|
+
|
|
98
|
+
### readable
|
|
99
|
+
|
|
100
|
+
- **Type:** `boolean`
|
|
101
|
+
- **Default:** `false`
|
|
102
|
+
|
|
103
|
+
Converts XML into a human readable format
|
|
104
|
+
|
|
105
|
+
### robots
|
|
106
|
+
|
|
107
|
+
- **Type:** `RobotOption[]`
|
|
108
|
+
- **Default:** `[{ userAgent: '*', allow: '/' }]`
|
|
109
|
+
|
|
110
|
+
RobotOption:
|
|
111
|
+
- **userAgent**: `string`
|
|
112
|
+
- **allow**?: `string | string[]`
|
|
113
|
+
- **disallow**?: `string | string[]`
|
|
114
|
+
- **crawlDelay**?: `number`
|
|
115
|
+
- **cleanParam**?: `string`
|
|
116
|
+
|
|
117
|
+
## License
|
|
118
|
+
|
|
119
|
+
MIT License © 2022 [jbaubree](https://github.com/jbaubree)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
interface RobotOption {
|
|
4
|
+
/**
|
|
5
|
+
* User-agent value.
|
|
6
|
+
* Example: Googlebot
|
|
7
|
+
*/
|
|
8
|
+
userAgent: string;
|
|
9
|
+
/**
|
|
10
|
+
* Allowed routes for corresponding User-agent.
|
|
11
|
+
* Example: '/'
|
|
12
|
+
*/
|
|
13
|
+
allow?: string | string[];
|
|
14
|
+
/**
|
|
15
|
+
* Disallowed routes for corresponding User-agent.
|
|
16
|
+
* Example: ['/admin', '/confidential']
|
|
17
|
+
*/
|
|
18
|
+
disallow?: string | string[];
|
|
19
|
+
/**
|
|
20
|
+
* Crawl-delay option for robot.
|
|
21
|
+
* Example: 2
|
|
22
|
+
*/
|
|
23
|
+
crawlDelay?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Clean-param option for robot.
|
|
26
|
+
* Example: 'ref /articles/'
|
|
27
|
+
*/
|
|
28
|
+
cleanParam?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Plugin options.
|
|
32
|
+
*/
|
|
33
|
+
interface Options {
|
|
34
|
+
/**
|
|
35
|
+
* Base URI
|
|
36
|
+
* @default 'http://localhost/'
|
|
37
|
+
*/
|
|
38
|
+
hostname: string;
|
|
39
|
+
/**
|
|
40
|
+
* Array of strings with dynamic routes.
|
|
41
|
+
* Example: ['/routes1', '/route2/sub-route']
|
|
42
|
+
* @default []
|
|
43
|
+
*/
|
|
44
|
+
dynamicRoutes: string[];
|
|
45
|
+
/**
|
|
46
|
+
* Output directory
|
|
47
|
+
* @default 'dist'
|
|
48
|
+
*/
|
|
49
|
+
outDir: string;
|
|
50
|
+
/**
|
|
51
|
+
* Change frequency option for sitemap
|
|
52
|
+
* @default 'daily'
|
|
53
|
+
*/
|
|
54
|
+
changefreq: string;
|
|
55
|
+
/**
|
|
56
|
+
* Priority option for sitemap
|
|
57
|
+
* @default 1
|
|
58
|
+
*/
|
|
59
|
+
priority: number;
|
|
60
|
+
/**
|
|
61
|
+
* Last modification option for sitemap
|
|
62
|
+
* @default new Date()
|
|
63
|
+
*/
|
|
64
|
+
lastmod: Date;
|
|
65
|
+
/**
|
|
66
|
+
* Converts XML into a human readable format
|
|
67
|
+
* @default false
|
|
68
|
+
*/
|
|
69
|
+
readable: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Robots policy
|
|
72
|
+
* @default [{ userAgent: '*', allow: '/' }]
|
|
73
|
+
*/
|
|
74
|
+
robots: RobotOption[];
|
|
75
|
+
}
|
|
76
|
+
declare type UserOptions = Partial<Options>;
|
|
77
|
+
interface ResolvedOptions extends Options {
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
declare function generateSitemap(options?: UserOptions): void;
|
|
81
|
+
declare function sitemapPlugin(options?: UserOptions): Plugin;
|
|
82
|
+
|
|
83
|
+
export { ResolvedOptions, RobotOption, UserOptions, sitemapPlugin as default, generateSitemap };
|