private string GetPreviewText(BlogItemPage.BlogItemPage page) { if (PreviewTextLength <= 0) { return(string.Empty); } var previewText = string.Empty; if (page.MainBody != null) { previewText = page.MainBody.ToHtmlString(); } if (string.IsNullOrEmpty(previewText)) { return(string.Empty); } //If the MainBody contains DynamicContents, replace those with an empty string var regexPattern = new StringBuilder(@"<span[\s\W\w]*?classid="""); regexPattern.Append(@"""[\s\W\w]*?</span>"); previewText = Regex.Replace(previewText, regexPattern.ToString(), string.Empty, RegexOptions.IgnoreCase | RegexOptions.Multiline); return(TextIndexer.StripHtml(previewText, PreviewTextLength)); }
private IEnumerable <BlogItemPageViewModel.TagItem> GetTags(BlogItemPage.BlogItemPage currentPage) { if (currentPage.Categories != null) { var allCategories = _contentLoader.GetItems(currentPage.Categories, CultureInfo.CurrentUICulture); return(allCategories. Select(cat => new BlogItemPageViewModel.TagItem() { Title = cat.Name, Url = _blogTagFactory.GetTagUrl(currentPage, cat.ContentLink), DisplayName = (cat as StandardCategory)?.Description, }).ToList()); } return(new List <BlogItemPageViewModel.TagItem>()); }