File tree 5 files changed +102
-3
lines changed 5 files changed +102
-3
lines changed Original file line number Diff line number Diff line change 25
25
"type" : " module" ,
26
26
"main" : " ./index.mjs" ,
27
27
"module" : " ./index.mjs" ,
28
+ "types" : " types" ,
28
29
"files" : [
29
- " index.mjs"
30
+ " index.mjs" ,
31
+ " types/index.d.ts"
30
32
],
31
33
"dependencies" : {
34
+ "@types/xast" : " ^1.0.0" ,
32
35
"bcp-47-normalize" : " ^1.0.0" ,
33
36
"unist-builder" : " ^2.0.0" ,
34
37
"xastscript" : " ^2.0.0"
35
38
},
36
39
"devDependencies" : {
37
40
"c8" : " ^7.0.0" ,
38
41
"concat-stream" : " ^2.0.0" ,
42
+ "dtslint" : " ^4.0.0" ,
39
43
"prettier" : " ^2.0.0" ,
40
44
"regenerate" : " ^1.0.0" ,
41
45
"remark-cli" : " ^9.0.0" ,
48
52
"format" : " remark . -qfo && prettier . -w --loglevel warn && xo --fix" ,
49
53
"test-api" : " node test.mjs" ,
50
54
"test-coverage" : " c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node --experimental-modules test.mjs" ,
51
- "test" : " npm run format && npm run test-coverage"
55
+ "test-types" : " dtslint types" ,
56
+ "test" : " npm run format && npm run test-coverage && npm run test-types"
52
57
},
53
58
"prettier" : {
54
59
"tabWidth" : 2 ,
78
83
"no-self-compare" : " off" ,
79
84
"unicorn/prefer-number-properties" : " off" ,
80
85
"unicorn/prefer-type-error" : " off"
81
- }
86
+ },
87
+ "ignores" : [
88
+ " types"
89
+ ]
82
90
},
83
91
"remarkConfig" : {
84
92
"plugins" : [
Original file line number Diff line number Diff line change
1
+ // Minimum TypeScript Version: 3.5
2
+
3
+ import { Root } from 'xast'
4
+
5
+ /**
6
+ * Entries represent a single URL and describe them with metadata.
7
+ */
8
+ export interface Entry {
9
+ /**
10
+ * Full URL.
11
+ *
12
+ * @see https://www.sitemaps.org/protocol.html#locdef
13
+ *
14
+ * @example 'https://example.org/'
15
+ */
16
+ url : string
17
+
18
+ /**
19
+ * Value indicating when the page last changed.
20
+ */
21
+ modified ?: Date | string | number
22
+
23
+ /**
24
+ * BCP 47 tag indicating the language of the page.
25
+ *
26
+ * @see https://github.com/wooorm/bcp-47
27
+ *
28
+ * @example 'en-GB'
29
+ */
30
+ lang ?: string
31
+
32
+ /**
33
+ * Translations of the page, where each key is a BCP 47 tag and each value an entry.
34
+ *
35
+ * Alternate resources inherit fields from the entry they are described in.
36
+ *
37
+ * @see https://github.com/wooorm/bcp-47
38
+ */
39
+ alternate ?: Record < string , string | Omit < Entry , 'lang' | 'alternate' > >
40
+ }
41
+
42
+ /**
43
+ * Build a sitemap.
44
+ *
45
+ * @param data URLs to build a sitemap for.
46
+ */
47
+ export function sitemap ( data : Array < string | Entry > ) : Root
Original file line number Diff line number Diff line change
1
+ import { sitemap } from 'xast-util-sitemap'
2
+
3
+ sitemap ( ) // $ExpectError
4
+ sitemap ( [
5
+ 'https://example.com' ,
6
+ { url : 'https://example.com' } ,
7
+ { url : 'https://example.com' , modified : new Date ( ) } ,
8
+ { url : 'https://example.com' , modified : Date . now ( ) } ,
9
+ { url : 'https://example.com' , modified : '01-02-2021' } ,
10
+ { url : 'https://example.com' , lang : 'en-GB' } ,
11
+ {
12
+ url : 'https://example.com' ,
13
+ lang : 'en-GB' ,
14
+ alternate : { 'de-AT' : 'https://example.at' }
15
+ } ,
16
+ {
17
+ url : 'https://example.com' ,
18
+ lang : 'en-GB' ,
19
+ alternate : { 'de-AT' : { url : 'https://example.at' , modified : Date . now ( ) } }
20
+ }
21
+ ] )
Original file line number Diff line number Diff line change
1
+ {
2
+ "compilerOptions" : {
3
+ "module" : " es2015" ,
4
+ "lib" : [" es2015" ],
5
+ "moduleResolution" : " node" ,
6
+ "strict" : true ,
7
+ "noEmit" : true ,
8
+ "baseUrl" : " ." ,
9
+ "paths" : {
10
+ "xast-util-sitemap" : [" ." ]
11
+ }
12
+ }
13
+ }
Original file line number Diff line number Diff line change
1
+
2
+ {
3
+ "extends" : " dtslint/dtslint.json" ,
4
+ "rules" : {
5
+ "no-redundant-jsdoc" : false ,
6
+ "no-redundant-jsdoc-2" : true ,
7
+ "semicolon" : false ,
8
+ "whitespace" : false
9
+ }
10
+ }
You can’t perform that action at this time.
0 commit comments