Skip to content

Commit bac456a

Browse files
committed
Add improved docs
1 parent ec9098b commit bac456a

File tree

1 file changed

+73
-20
lines changed

1 file changed

+73
-20
lines changed

readme.md

Lines changed: 73 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,43 @@
88
[![Backers][backers-badge]][collective]
99
[![Chat][chat-badge]][chat]
1010

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?
1335

1436
This package focusses on a small set of widely used parts of sitemaps.
1537
It has a few good options instead of overwhelming with everything that *could*
1638
be done.
1739
If you do need more things, well: this utility gives you a syntax tree, which
1840
you can change.
1941

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.
2244
Wrapping this project into something that generates sitemap index files is left
2345
as an exercise to the reader.
2446

47+
You don’t always need a sitemap.
2548
[See Google’s recommendations for whether you need a
2649
sitemap](https://developers.google.com/search/docs/advanced/sitemaps/overview)
2750

@@ -32,18 +55,28 @@ sitemap changes to Google.
3255

3356
## Install
3457

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][]:
3960

4061
```sh
4162
npm install xast-util-sitemap
4263
```
4364

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]:
4572

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
4780

4881
```js
4982
import {sitemap} from 'xast-util-sitemap'
@@ -66,7 +99,7 @@ const tree = sitemap([
6699
console.log(toXml(tree))
67100
```
68101

69-
Now, running `node example.js` yields (pretty printed):
102+
Yields (pretty printed):
70103

71104
```xml
72105
<?xml version="1.0" encoding="utf-8"?>
@@ -104,7 +137,7 @@ Now, running `node example.js` yields (pretty printed):
104137

105138
## API
106139

107-
This package exports the following identifiers: `sitemap`.
140+
This package exports the identifier `sitemap`.
108141
There is no default export.
109142

110143
### `sitemap(data)`
@@ -114,12 +147,12 @@ Build a sitemap.
114147
###### `data`
115148

116149
URLs to build a sitemap for.
117-
`data` is an `Array.<url | Entry>`.
150+
`data` is an `Array<url | Entry>`.
118151
`url` is `string` and equivalent to an `{url: url}` entry.
119152

120153
###### Returns
121154

122-
[`Root`][root][xast][] root.
155+
[xast][] root ([`Root`][root]).
123156

124157
### `Entry`
125158

@@ -142,7 +175,7 @@ value for `new Date(x)`, optional).
142175
###### `entry.alternate`
143176

144177
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:
146179
'https://example.nl/'}`).
147180

148181
Alternate resources “inherit” fields (`modified`) from the entry they are
@@ -181,6 +214,18 @@ Or define them separately:
181214
]
182215
```
183216

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+
184229
## Security
185230

186231
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
198243

199244
## Contribute
200245

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.
203248
See [`support.md`][support] for ways to get help.
204249

205250
This project has a [code of conduct][coc].
@@ -240,15 +285,23 @@ abide by its terms.
240285

241286
[npm]: https://docs.npmjs.com/cli/install
242287

288+
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
289+
290+
[esmsh]: https://esm.sh
291+
292+
[typescript]: https://www.typescriptlang.org
293+
243294
[license]: license
244295

245296
[author]: https://wooorm.com
246297

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
248301

249-
[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md
302+
[support]: https://github.com/syntax-tree/.github/blob/main/support.md
250303

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
252305

253306
[xast]: https://github.com/syntax-tree/xast
254307

0 commit comments

Comments
 (0)