sitemapEntryMap = new LinkedHashMap<>(2, 1);
sitemapEntryMap.put("loc", sitemapEntry.getLoc());
if (StringUtils.isNotBlank(sitemapEntry.getLastmod())) {
sitemapEntryMap.put("lastmod", sitemapEntry.getLastmod());
}
- ChangeFreqEnum changefreq = sitemapEntry.getChangefreq();
- if (changefreq != null) {
- sitemapEntryMap.put("changefreq", changefreq.name().toLowerCase());
- }
- if (sitemapEntry.getPriority() != null) {
- sitemapEntryMap.put("priority", sitemapEntry.getPriority().toString());
- }
return sitemapEntryMap;
}
diff --git a/src/main/java/run/halo/sitemap/SitemapEntry.java b/src/main/java/run/halo/sitemap/SitemapEntry.java
index 960cd51..130a843 100644
--- a/src/main/java/run/halo/sitemap/SitemapEntry.java
+++ b/src/main/java/run/halo/sitemap/SitemapEntry.java
@@ -15,11 +15,8 @@ public class SitemapEntry {
* Parent tag for each URL entry. The remaining tags are children of this tag.
* required.
*/
+ @NonNull
private String loc;
private String lastmod;
-
- private ChangeFreqEnum changefreq;
-
- private Double priority;
}
diff --git a/src/main/java/run/halo/sitemap/SitemapGeneratorOptions.java b/src/main/java/run/halo/sitemap/SitemapGeneratorOptions.java
index 6c87f34..c529578 100644
--- a/src/main/java/run/halo/sitemap/SitemapGeneratorOptions.java
+++ b/src/main/java/run/halo/sitemap/SitemapGeneratorOptions.java
@@ -3,7 +3,6 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
-import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.util.Set;
import lombok.Builder;
@@ -26,70 +25,17 @@ public class SitemapGeneratorOptions {
@NonNull
private URL siteUrl;
- @Builder.Default
- private String fileNamePrefix = "sitemap";
-
- @Builder.Default
- private boolean allowEmptySitemap = false;
-
- @Builder.Default
- private boolean allowMultipleSitemaps = true;
-
@Builder.Default
private DateTimeFormatter dateTimeFormatter = W3cDatetimeFormat.SECOND_FORMATTER;
- /**
- * Split large sitemap into multiple files by specifying sitemap size. Default 5000.
- */
- @Builder.Default
- private int sitemapSize = 5000;
-
- @Builder.Default
- private boolean autoValidate = false;
-
- @Builder.Default
- private boolean gzip = false;
-
- @Builder.Default
- private ChangeFreqEnum changefreq = ChangeFreqEnum.DAILY;
-
- /**
- * How to assign sitemap priorities:
- *
- * 1.0-0.8
- * Homepage, product information, landing pages.
- *
- * 0.7-0.4
- * News articles, some weather services, blog posts, category pages, pages that no site would be complete without.
- *
- * 0.3-0.0
- * FAQs, outdated info, old press releases, completely static pages that are still relevant enough to keep from deleting entirely.
- *
- *
- * @see
- * xml-sitemap-priority-changefreq
- * @see
- * xml-sitemap-priority-changefreq
- */
- @Builder.Default
- private double priority = 0.7;
-
/**
* Array of relative paths (wildcard pattern supported) to exclude from listing on sitemap
* .xml or sitemap-*.xml.
*
* e.g.: ['/page-0', '/page-*', '/private/*'].
- * Apart from this option next-sitemap also offers a custom transform option which could be
- * used to exclude urls that match specific patterns
*/
private Set exclude;
- /**
- * Generate index sitemaps. Default true.
- */
- @Builder.Default
- private boolean generateIndexSitemap = true;
-
public SitemapEntry transform(UrlEntryMeta context) {
String escapedUrl = UrlUtils.escapeSitemapUrl(context.getUrl());
String loc = UrlUtils.toURI(escapedUrl).normalize().toASCIIString();
@@ -97,21 +43,11 @@ public SitemapEntry transform(UrlEntryMeta context) {
loc = getSiteUri().resolve(escapedUrl).normalize().toASCIIString();
}
- var builder = SitemapEntry.builder()
- .loc(loc)
- .changefreq(changefreq);
-
- if (context.getPriority() != null) {
- builder.priority(context.getPriority());
- } else {
- builder.priority(priority);
- }
+ var builder = SitemapEntry.builder().loc(loc);
if (context.getLastModifiedTime() != null) {
builder.lastmod(
W3cDatetimeFormat.format(context.getLastModifiedTime(), dateTimeFormatter));
- } else {
- builder.lastmod(W3cDatetimeFormat.format(Instant.now(), dateTimeFormatter));
}
return builder.build();
diff --git a/src/test/java/run/halo/sitemap/SitemapBuilderTest.java b/src/test/java/run/halo/sitemap/SitemapBuilderTest.java
index dc05fcf..7756629 100644
--- a/src/test/java/run/halo/sitemap/SitemapBuilderTest.java
+++ b/src/test/java/run/halo/sitemap/SitemapBuilderTest.java
@@ -20,14 +20,10 @@ void buildSitemapXml() {
entries.add(SitemapEntry.builder()
.loc("https://halo.run/about")
.lastmod("2022-11-12T13:57:43.898+0800")
- .changefreq(ChangeFreqEnum.DAILY)
- .priority(0.7)
.build());
entries.add(SitemapEntry.builder()
.loc("https://halo.run/categories")
.lastmod("2022-11-12T13:57:43.898+0800")
- .changefreq(ChangeFreqEnum.DAILY)
- .priority(0.7)
.build());
String s = new SitemapBuilder().buildSitemapXml(entries);
assertEquals("""
@@ -41,16 +37,12 @@ void buildSitemapXml() {
xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
https://halo.run/about
2022-11-12T13:57:43.898+0800
- daily
- 0.7
https://halo.run/categories
2022-11-12T13:57:43.898+0800
- daily
- 0.7
""", s);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/run/halo/sitemap/SitemapGeneratorOptionsTest.java b/src/test/java/run/halo/sitemap/SitemapGeneratorOptionsTest.java
index 22ec749..54e9da2 100644
--- a/src/test/java/run/halo/sitemap/SitemapGeneratorOptionsTest.java
+++ b/src/test/java/run/halo/sitemap/SitemapGeneratorOptionsTest.java
@@ -1,6 +1,7 @@
package run.halo.sitemap;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.net.MalformedURLException;
import java.net.URL;
@@ -19,27 +20,23 @@ void transform() throws MalformedURLException {
SitemapGeneratorOptions options = SitemapGeneratorOptions.builder()
.siteUrl(new URL("https://halo.run"))
.build();
+
SitemapEntry entry = options.transform(new UrlEntryMeta("/about"));
assertEquals("https://halo.run/about", entry.getLoc());
- assertEquals(ChangeFreqEnum.DAILY, entry.getChangefreq());
- assertEquals(0.7, entry.getPriority());
+ assertNull(entry.getLastmod());
entry = options.transform(new UrlEntryMeta("/archives"));
assertEquals("https://halo.run/archives", entry.getLoc());
- assertEquals(ChangeFreqEnum.DAILY, entry.getChangefreq());
- assertEquals(0.7, entry.getPriority());
+ assertNull(entry.getLastmod());
entry = options.transform(new UrlEntryMeta("/categories/ümlat/>&>中"));
assertEquals("https://halo.run/categories/%C3%BCmlat/>&>%E4%B8%AD",
entry.getLoc());
- assertEquals(ChangeFreqEnum.DAILY, entry.getChangefreq());
- assertEquals(0.7, entry.getPriority());
+ assertNull(entry.getLastmod());
entry = options.transform(new UrlEntryMeta("https://guqing.xyz/hello-中国<>&"));
assertEquals("https://guqing.xyz/hello-%E4%B8%AD%E5%9B%BD<>&",
entry.getLoc());
-
- assertEquals(ChangeFreqEnum.DAILY, entry.getChangefreq());
- assertEquals(0.7, entry.getPriority());
+ assertNull(entry.getLastmod());
}
-}
\ No newline at end of file
+}