Created
December 31, 2015 18:42
-
-
Save kgiszewski/41f7fdeeadd5a9e68054 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using Umbraco.Core.Models; | |
| using Umbraco.Web; | |
| namespace KGLLC.Umbraco.Helpers | |
| { | |
| public static class PublishedContentExtensions | |
| { | |
| public static string ToPublishedDateLong(this IPublishedContent content) | |
| { | |
| return content.ToPublishedDate().ToString("D"); | |
| } | |
| public static string ToPublishedDateShort(this IPublishedContent content) | |
| { | |
| return content.ToPublishedDate().ToString("dd MMM"); | |
| } | |
| public static DateTime ToPublishedDate(this IPublishedContent content) | |
| { | |
| var publishedDate = content.GetPropertyValue<DateTime>("publishedDate"); | |
| if (publishedDate == DateTime.MinValue) | |
| { | |
| return content.CreateDate; | |
| } | |
| return content.GetPropertyValue<DateTime>("publishedDate"); | |
| } | |
| public static string ToMetaDescription(this IPublishedContent content) | |
| { | |
| if (content.DocumentTypeAlias == "BlogPostPage") | |
| { | |
| var umbHelper = new UmbracoHelper(UmbracoContext.Current); | |
| return umbHelper.StripHtml(content.GetPropertyValue<string>("teaseDescription")).ToString().Replace("\n", " "); | |
| } | |
| return string.Format("Kevin.Giszewski.com - {0}", content.Name); | |
| } | |
| public static string ToTitleTag(this IPublishedContent content) | |
| { | |
| return string.Format("Kevin.Giszewski.com - {0}", content.Name); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment