Beispiel #1
0
        public async Task <String> GetSiteMapXmlAsync(String baseUrl,
                                                      CancellationToken cancel = default)
        {
            var blogStories = await _blogStoryRepository.GetAsync(BlogStoryQuery.AllPublished, cancel);

            var siteMapBuilder = new SitemapBuilder();

            var modifiedDate = blogStories.Any()
                ? (DateTime?)blogStories.First().ModifiedDate
                : null;

            siteMapBuilder.AddUrl(baseUrl, modifiedDate, ChangeFrequency.Daily);

            var tags = await _tagManager.GetAllPublishedAsync(cancel);

            foreach (var tag in tags)
            {
                siteMapBuilder.AddUrl(tag.ToSitemapItem(baseUrl));
            }

            foreach (var blogStory in blogStories)
            {
                siteMapBuilder.AddUrl(blogStory.ToSitemapItem(baseUrl));
            }

            return(siteMapBuilder.ToString());
        }