public IActionResult SiteMap() { var publishedPosts = _blogService.GetPublishedPosts(); var urlSet = new SiteMapUrlSet(); var urls = new List <SiteMapUrl> { new SiteMapUrl { Loc = AddressHelper.GetAddress(_appConfig.BlogAddress), ChangeFreq = "weekly", LastMod = DateTime.UtcNow.ToChinaTime().ToDate(), Priority = 1.0 }, new SiteMapUrl { Loc = AddressHelper.GetAddress(_appConfig.BlogAddress, true, "about"), ChangeFreq = "monthly", LastMod = DateTime.UtcNow.ToChinaTime().ToDate(), Priority = 0.9 }, new SiteMapUrl { Loc = AddressHelper.GetAddress(_appConfig.BlogAddress, true, "archive"), ChangeFreq = "weekly", LastMod = DateTime.UtcNow.ToChinaTime().ToDate(), Priority = 0.8 }, new SiteMapUrl { Loc = AddressHelper.GetAddress(_appConfig.BlogAddress, true, "category"), ChangeFreq = "weekly", LastMod = DateTime.UtcNow.ToChinaTime().ToDate(), Priority = 0.7 }, new SiteMapUrl { Loc = AddressHelper.GetAddress(_appConfig.BlogAddress, true, "tag"), ChangeFreq = "weekly", LastMod = DateTime.UtcNow.ToChinaTime().ToDate(), Priority = 0.6 } }; foreach (var publishedPost in publishedPosts) { urls.Add(new SiteMapUrl { Loc = publishedPost.FullUrlWithBaseAddress, ChangeFreq = "daily", LastMod = publishedPost.LastUpdateTimeUtc.ToChinaTime().ToDate(), Priority = 0.5 }); } urlSet.Urls = urls; var xml = SerializeHelper.ToXml(urlSet, ns: "http://www.sitemaps.org/schemas/sitemap/0.9"); return(Content(xml, "text/xml", Encoding.UTF8)); }
public string GetLink() { return(AddressHelper.GetAddress(false, "category", $"#{Link}")); }