@@ -12,7 +12,7 @@ First add this library to classpath:
12
12
<dependency>
13
13
<groupId>cz.jiripinkas</groupId>
14
14
<artifactId>jsitemapgenerator</artifactId>
15
- <version>3.12 </version>
15
+ <version>3.13 </version>
16
16
</dependency>
17
17
18
18
If you want to use "ping google / bing" functionality, also add this library to classpath:
@@ -27,7 +27,8 @@ If you want to use "ping google / bing" functionality, also add this library to
27
27
28
28
``` java
29
29
String sitemap = SitemapGenerator . of(" https://example.com" )
30
- .addPage(WebPage . of(" foo.html" )) // simplest way of creating web page
30
+ .addPage(" foo2.html" ) // simplest way how to add page - shorthand for addPage(WebPage.of("foo2.html"))
31
+ .addPage(WebPage . of(" foo1.html" )) // same as addPage("foo1.html")
31
32
.addPage(WebPage . builder(). name(" bar.html" ). build()) // builder is more complex
32
33
.addPage(WebPage . builder(). maxPriorityRoot(). build()) // builder has lots of useful methods
33
34
.toString();
@@ -38,8 +39,8 @@ or sitemap in gzip format:
38
39
``` java
39
40
byte [] sitemap = SitemapGenerator . of(" https://example.com" )
40
41
.addPage(WebPage . builder(). maxPriorityRoot(). build())
41
- .addPage(WebPage . of( " foo.html" ) )
42
- .addPage(WebPage . of( " bar.html" ) )
42
+ .addPage(" foo.html" )
43
+ .addPage(" bar.html" )
43
44
.toGzipByteArray();
44
45
```
45
46
@@ -50,11 +51,11 @@ String sitemap = SitemapGenerator.of("https://example.com")
50
51
.addPage(WebPage . builder(). maxPriorityRoot(). build()) // URL will be: "/"
51
52
.defaultExtension(" html" )
52
53
.defaultDir(" dir1" )
53
- .addPage(WebPage . of( " foo" ) ) // URL will be: "dir1/foo.html"
54
- .addPage(WebPage . of( " bar" ) ) // URL will be: "dir1/bar.html"
54
+ .addPage(" foo" ) // URL will be: "dir1/foo.html"
55
+ .addPage(" bar" ) // URL will be: "dir1/bar.html"
55
56
.defaultDir(" dir2" )
56
- .addPage(WebPage . of( " hello" ) ) // URL will be: "dir2/hello.html"
57
- .addPage(WebPage . of( " yello" ) ) // URL will be: "dir2/yello.html"
57
+ .addPage(" hello" ) // URL will be: "dir2/hello.html"
58
+ .addPage(" yello" ) // URL will be: "dir2/yello.html"
58
59
// btw. specifying dir and / or extension on WebPage overrides default settings
59
60
.addPage(WebPage . builder(). dir(" dir3" ). extension(null ). name(" test" ). build()) // "dir3/test"
60
61
.resetDefaultDir() // resets default dir
@@ -97,8 +98,8 @@ or to store it to file & ping google:
97
98
SitemapGenerator sg = SitemapGenerator . of(" https://example.com" );
98
99
// add some URLs
99
100
sg. addPage(WebPage . builder(). maxPriorityRoot(). changeFreqNever(). lastModNow(). build())
100
- .addPage(WebPage . of( " foo.html" ) )
101
- .addPage(WebPage . of( " bar.html" ) );
101
+ .addPage(" foo.html" )
102
+ .addPage(" bar.html" );
102
103
// generate sitemap and save it to file ./sitemap.xml
103
104
sg. constructAndSaveSitemap(Paths . get(" sitemap.xml" ));
104
105
// inform Google that this sitemap has changed
@@ -109,8 +110,8 @@ sg.pingGoogle(); // this requires okhttp in classpath!!!
109
110
110
111
``` java
111
112
String sitemapIndex = SitemapIndexGenerator . of(" https://javalibs.com" )
112
- .addPage(WebPage . of( " sitemap-plugins.xml" ) )
113
- .addPage(WebPage . of( " sitemap-archetypes.xml" ) )
113
+ .addPage(" sitemap-plugins.xml" )
114
+ .addPage(" sitemap-archetypes.xml" )
114
115
.toString();
115
116
```
116
117
0 commit comments