Exemplo n.º 1
0
        public IActionResult Index()
        {
            var sitemapData = new List <SitemapItem>();

            sitemapData.AddRange(GeneralPages("https://someurl.com"));

            var sitemap = sitemapService.GenerateSitemap(data =>
            {
                data.AddRange(sitemapData);
            });

            return(Content(sitemap, "application/xml"));
        }
Exemplo n.º 2
0
        private async Task GenerateSitemap()
        {
            var sitemapPath = Path.Combine(_hostingEnvironment.WebRootPath, "sitemap.xml");

            var sitemap = _sitemapService.GenerateSitemap((await _entryService.GetPublishedEntries())
                                                          .Select(e => new Page()
            {
                Url          = string.Concat("/article/", e.Slug),
                LastModified = e.LastModified
            }));

            if (sitemap != null)
            {
                sitemap.Save(sitemapPath);
            }
        }