fixed missing namespace in sitemap

This commit is contained in:
Mia Rose Winter 2024-02-06 22:35:32 +01:00
parent 0e2f6ffae9
commit 4f34b4911a
Signed by: miawinter
GPG key ID: 4B6F6A83178F595E

View file

@ -22,7 +22,8 @@ public class SitemapController(ApplicationDbContext context) : ControllerBase {
var host = new Uri($"https://{Request.Host}{Request.PathBase}", UriKind.Absolute);
var articles = await Context.Set<Article>().OrderBy(a => a.PublishDate).ToListAsync();
var document = new XDocument(new XElement("urlset")) {
XNamespace nameSpace = "http://www.sitemaps.org/schemas/sitemap/0.9";
var document = new XDocument(new XElement(nameSpace + "urlset", new XAttribute("xmlns", nameSpace))) {
Declaration = new XDeclaration("1.0", Encoding.UTF8.ToString(), null),
};