Skip to content

Commit

Permalink
Allow datetime formatting for sitemap
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickdemooij9 committed Aug 13, 2023
1 parent 2b97053 commit 10e4e50
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ private IEnumerable<XElement> ToXmlElements(IEnumerable<SitemapNodeItem> nodes)
var selfItem = new XElement(_namespace + "url");
selfItem.Add(new XElement(_namespace + "loc", node.Url));
if (node.LastModifiedDate != null)
selfItem.Add(new XElement(_namespace + "lastmod", node.LastModifiedDate.Value.ToString("yyyy-MM-dd")));
selfItem.Add(new XElement(_namespace + "lastmod", node.LastModifiedDate.Value.ToString(_settings.LastModifiedFormat)));
if (!string.IsNullOrWhiteSpace(node.ChangeFrequency))
selfItem.Add(new XElement(_namespace + "changefreq", node.ChangeFrequency));
if (node.Priority != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class SitemapAppSettingsModel
public string PriorityFieldAlias { get; set; } = "priority";

public string ReturnContentType { get; set; } = "application/xml";
public string LastModifiedFormat { get; set; } = "yyyy-MM-ddTHH:mm:sszzz";
public string[] DisabledModules { get; set; } = Array.Empty<string>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class SitemapConfig
public string PriorityFieldAlias { get; set; } = "priority";

public string ReturnContentType { get; set; } = "application/xml";
public string LastModifiedFormat { get; set; } = "yyyy-MM-ddTHH:mm:sszzz";
public string[] DisabledModules { get; set; } = Array.Empty<string>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public override SitemapConfig GetSettings()
ChangeFrequencyFieldAlias = settings.ChangeFrequencyFieldAlias,
PriorityFieldAlias = settings.PriorityFieldAlias,
ReturnContentType = settings.ReturnContentType,
LastModifiedFormat = settings.LastModifiedFormat,
DisabledModules = settings.DisabledModules
};
}
Expand Down

0 comments on commit 10e4e50

Please sign in to comment.