8
8
[ ![ Backers] [ backers-badge ]] [ collective ]
9
9
[ ![ Chat] [ chat-badge ]] [ chat ]
10
10
11
- ** [ xast] [ ] ** utility to build a [ ` sitemap.xml ` ] [ sitemap ] .
12
- Supports localization as suggested by [ Google] [ ] .
11
+ [ xast] [ ] utility to build a [ ` sitemap.xml ` ] [ sitemap ] .
12
+
13
+ ## Contents
14
+
15
+ * [ What is this?] ( #what-is-this )
16
+ * [ When should I use this?] ( #when-should-i-use-this )
17
+ * [ Install] ( #install )
18
+ * [ Use] ( #use )
19
+ * [ API] ( #api )
20
+ * [ ` sitemap(data) ` ] ( #sitemapdata )
21
+ * [ ` Entry ` ] ( #entry )
22
+ * [ Types] ( #types )
23
+ * [ Compatibility] ( #compatibility )
24
+ * [ Security] ( #security )
25
+ * [ Related] ( #related )
26
+ * [ Contribute] ( #contribute )
27
+ * [ License] ( #license )
28
+
29
+ ## What is this?
30
+
31
+ This package helps you build a [ ` sitemap.xml ` ] [ sitemap ] .
32
+ It supports localization as suggested by [ Google] [ ] .
33
+
34
+ ## When should I use this?
13
35
14
36
This package focusses on a small set of widely used parts of sitemaps.
15
37
It has a few good options instead of overwhelming with everything that * could*
16
38
be done.
17
39
If you do need more things, well: this utility gives you a syntax tree, which
18
40
you can change.
19
41
20
- Intended for sites with up to 50k URLs and a resulting serialized contents of
21
- up to 50MB.
42
+ This proejct is intended for sites with up to 50k URLs and a resulting
43
+ serialized contents of up to 50MB.
22
44
Wrapping this project into something that generates sitemap index files is left
23
45
as an exercise to the reader.
24
46
47
+ You don’t always need a sitemap.
25
48
[ See Google’s recommendations for whether you need a
26
49
sitemap] ( https://developers.google.com/search/docs/advanced/sitemaps/overview )
27
50
@@ -32,18 +55,28 @@ sitemap changes to Google.
32
55
33
56
## Install
34
57
35
- This package is [ ESM only] ( https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c ) :
36
- Node 12+ is needed to use it and it must be ` import ` ed instead of ` require ` d.
37
-
38
- [ npm] [ ] :
58
+ This package is [ ESM only] [ esm ] .
59
+ In Node.js (version 12.20+, 14.14+, 16.0+, or 18.0+), install with [ npm] [ ] :
39
60
40
61
``` sh
41
62
npm install xast-util-sitemap
42
63
```
43
64
44
- ## Use
65
+ In Deno with [ ` esm.sh ` ] [ esmsh ] :
66
+
67
+ ``` js
68
+ import {sitemap } from ' https://esm.sh/xast-util-sitemap@1'
69
+ ```
70
+
71
+ In browsers with [ ` esm.sh ` ] [ esmsh ] :
45
72
46
- Say we have the following module, ` example.js `
73
+ ``` html
74
+ <script type =" module" >
75
+ import {sitemap } from ' https://esm.sh/xast-util-sitemap@1?bundle'
76
+ </script >
77
+ ```
78
+
79
+ ## Use
47
80
48
81
``` js
49
82
import {sitemap } from ' xast-util-sitemap'
@@ -66,7 +99,7 @@ const tree = sitemap([
66
99
console .log (toXml (tree))
67
100
```
68
101
69
- Now, running ` node example.js ` yields (pretty printed):
102
+ Yields (pretty printed):
70
103
71
104
``` xml
72
105
<?xml version =" 1.0" encoding =" utf-8" ?>
@@ -104,7 +137,7 @@ Now, running `node example.js` yields (pretty printed):
104
137
105
138
## API
106
139
107
- This package exports the following identifiers: ` sitemap ` .
140
+ This package exports the identifier ` sitemap ` .
108
141
There is no default export.
109
142
110
143
### ` sitemap(data) `
@@ -114,12 +147,12 @@ Build a sitemap.
114
147
###### ` data `
115
148
116
149
URLs to build a sitemap for.
117
- ` data ` is an ` Array. <url | Entry> ` .
150
+ ` data ` is an ` Array<url | Entry> ` .
118
151
` url ` is ` string ` and equivalent to an ` {url: url} ` entry.
119
152
120
153
###### Returns
121
154
122
- [ ` Root ` ] [ root ] — [ xast ] [ ] root.
155
+ [ xast ] [ ] root ( [ ` Root ` ] [ root ] ) .
123
156
124
157
### ` Entry `
125
158
@@ -142,7 +175,7 @@ value for `new Date(x)`, optional).
142
175
###### ` entry.alternate `
143
176
144
177
Translations of the page, where each key is a [ BCP 47] [ bcp47 ] tag and each value
145
- an entry (` Object< url | Entry>` , optional, example: `{nl:
178
+ an entry (` Record<string, url | Entry>` , optional, example: `{nl:
146
179
'https://example.nl/'}` ).
147
180
148
181
Alternate resources “inherit” fields (` modified ` ) from the entry they are
@@ -181,6 +214,18 @@ Or define them separately:
181
214
]
182
215
```
183
216
217
+ ## Types
218
+
219
+ This package is fully typed with [ TypeScript] [ ] .
220
+ It exports the additional types ` Alternate ` and ` Entry ` .
221
+
222
+ ## Compatibility
223
+
224
+ Projects maintained by the unified collective are compatible with all maintained
225
+ versions of Node.js.
226
+ As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
227
+ Our projects sometimes work with older versions, but this is not guaranteed.
228
+
184
229
## Security
185
230
186
231
XML can be a dangerous language: don’t trust user-provided data.
@@ -198,8 +243,8 @@ of the `sitemap.xml` file is also an owner
198
243
199
244
## Contribute
200
245
201
- See [ ` contributing.md ` in ` syntax-tree/.github ` ] [ contributing ] for ways to get
202
- started.
246
+ See [ ` contributing.md ` ] [ contributing ] in [ ` syntax-tree/.github ` ] [ health ] for
247
+ ways to get started.
203
248
See [ ` support.md ` ] [ support ] for ways to get help.
204
249
205
250
This project has a [ code of conduct] [ coc ] .
@@ -240,15 +285,23 @@ abide by its terms.
240
285
241
286
[ npm ] : https://docs.npmjs.com/cli/install
242
287
288
+ [ esm ] : https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
289
+
290
+ [ esmsh ] : https://esm.sh
291
+
292
+ [ typescript ] : https://www.typescriptlang.org
293
+
243
294
[ license ] : license
244
295
245
296
[ author ] : https://wooorm.com
246
297
247
- [ contributing ] : https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
298
+ [ health ] : https://github.com/syntax-tree/.github
299
+
300
+ [ contributing ] : https://github.com/syntax-tree/.github/blob/main/contributing.md
248
301
249
- [ support ] : https://github.com/syntax-tree/.github/blob/HEAD /support.md
302
+ [ support ] : https://github.com/syntax-tree/.github/blob/main /support.md
250
303
251
- [ coc ] : https://github.com/syntax-tree/.github/blob/HEAD /code-of-conduct.md
304
+ [ coc ] : https://github.com/syntax-tree/.github/blob/main /code-of-conduct.md
252
305
253
306
[ xast ] : https://github.com/syntax-tree/xast
254
307
0 commit comments