Skip to content

Commit 6a5f671

Browse files
committed
Merge branch 'sitemap-compression' into develop
2 parents 32e8289 + df7b0d7 commit 6a5f671

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

OnTopic.AspNetCore.Mvc/Controllers/SitemapController.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ public SitemapController(ITopicRepository topicRepository) {
9090
/// <summary>
9191
/// Provides the Sitemap.org sitemap for the site.
9292
/// </summary>
93+
/// <param name="indent">Optionally enables indentation of XML elements in output for human readability.</param>
9394
/// <returns>The site's homepage view.</returns>
94-
public virtual ActionResult Index() {
95+
public virtual ActionResult Index(bool indent = false) {
9596

9697
/*------------------------------------------------------------------------------------------------------------------------
9798
| Ensure topics are loaded
@@ -109,11 +110,12 @@ public virtual ActionResult Index() {
109110
\-----------------------------------------------------------------------------------------------------------------------*/
110111
var declaration = new XDeclaration("1.0", "utf-8", "no");
111112
var sitemap = GenerateSitemap(rootTopic);
113+
var settings = indent? SaveOptions.None : SaveOptions.DisableFormatting;
112114

113115
/*------------------------------------------------------------------------------------------------------------------------
114116
| Return the homepage view
115117
\-----------------------------------------------------------------------------------------------------------------------*/
116-
return Content(declaration.ToString() + sitemap.ToString(), "text/xml");
118+
return Content(declaration.ToString() + sitemap.ToString(settings), "text/xml");
117119

118120
}
119121

0 commit comments

Comments
 (0)