/// <summary> /// Renders the OpenGraph header tags for an article. /// </summary> /// <param name="htmlHelper">The HTML helper.</param> /// <param name="content">The content.</param> /// <returns>The <see cref="IHtmlString"/>.</returns> /// <exception cref="T:System.Web.HttpException">The Web application is running under IIS 7 in Integrated mode.</exception> /// <exception cref="T:System.InvalidOperationException">The current <see cref="T:System.Uri" /> instance is not an absolute instance.</exception> /// <exception cref="T:System.ArgumentException">The specified <see cref="UriPartial.Authority"/> is not valid.</exception> /// <exception cref="T:System.MemberAccessException">The <see cref="T:System.Lazy`1" /> instance is initialized to use the default constructor of the type that is being lazily initialized, and permissions to access the constructor are missing.</exception> /// <exception cref="T:System.MissingMemberException">The <see cref="T:System.Lazy`1" /> instance is initialized to use the default constructor of the type that is being lazily initialized, and that type does not have a public, parameterless constructor.</exception> public static IHtmlString OpenGraphArticle(this HtmlHelper htmlHelper, ISocialMediaTags content) { OpenGraphArticle openGraphContent = content.ToOpenGraphArticle(); return(openGraphContent == null ? MvcHtmlString.Empty : htmlHelper.OpenGraph(openGraphMetadata: openGraphContent)); }
/// <summary> /// Converts the <param name="content"></param> to an <see cref="Boilerplate.Web.Mvc.OpenGraph.OpenGraphArticle"/>. /// </summary> /// <param name="content">The content.</param> /// <returns>The <see cref="Boilerplate.Web.Mvc.OpenGraph.OpenGraphArticle"/> for the <param name="content"></param>.</returns> /// <exception cref="T:System.Web.HttpException">The Web application is running under IIS 7 in Integrated mode.</exception> /// <exception cref="T:System.ArgumentException">The specified <see cref="UriPartial.Authority"/> is not valid.</exception> /// <exception cref="T:System.InvalidOperationException">The current <see cref="T:System.Uri" /> instance is not an absolute instance.</exception> /// <exception cref="T:System.MemberAccessException">The <see cref="T:System.Lazy`1" /> instance is initialized to use the default constructor of the type that is being lazily initialized, and permissions to access the constructor are missing.</exception> /// <exception cref="T:System.MissingMemberException">The <see cref="T:System.Lazy`1" /> instance is initialized to use the default constructor of the type that is being lazily initialized, and that type does not have a public, parameterless constructor.</exception> public static OpenGraphArticle ToOpenGraphArticle(this ISocialMediaTags content) { string imageUrl = content.TeaserImage.GetUrl(); if (!string.IsNullOrWhiteSpace(value: imageUrl)) { return(new OpenGraphArticle( !string.IsNullOrWhiteSpace(value: content.DisplayName) ? content.DisplayName : content.Name, new OpenGraphImage(imageUrl: imageUrl), content.GetUrl())); } Log.Debug($"[Social Tags] Page with id '{content.ContentLink.ID}' has no teaser image defined."); return(null); }