ps-team
10/27/2017 - 8:05 AM

OpenGraph data output - Razor and metadata needed for displaying better Facebook and Twitter share images for each webpage. Just add to a ba

OpenGraph data output - Razor and metadata needed for displaying better Facebook and Twitter share images for each webpage. Just add to a base razor file.

var OpenGraphImage = "https://www.cumbria.police.uk/SiteElements/Images/Facebook-logo.png";
    if(CurrentNode.ThumbnailUrl!="") {
    	OpenGraphImage = "https://www.cumbria.police.uk" + CurrentNode.ThumbnailUrl;
    }
  	
    CurrentContext.Page.Head.Add("meta", new { property = "og:title", content = CurrentNode.Title });
    CurrentContext.Page.Head.Add("meta", new { property = "og:description", content = CurrentNode.Data.Description });
 	CurrentContext.Page.Head.Add("meta", new { property = "og:image", content = OpenGraphImage }); 
    CurrentContext.Page.Head.Add("meta", new { property = "og:url", content = CurrentNode.FullPath }); 
    CurrentContext.Page.Head.Add("meta", new { property = "og:site_name", content = "Cumbria Constabulary" }); 
    CurrentContext.Page.Head.Add("meta", new { property = "og:type", content = "Article" });