Skip to content

Commit

Permalink
Merge pull request #2089 from vitali-karmanov/master
Browse files Browse the repository at this point in the history
Open Graph Tags Incomplete
  • Loading branch information
tidyui authored Aug 16, 2024
2 parents d06c1b0 + f43406f commit b176047
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions core/Piranha.AspNetCore/Extensions/PiranhaHtmlExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,26 +70,26 @@ public static HtmlString MetaTags(this IApplicationService app, IMeta content, b
// Generate open graph tags
if (content is PageBase page && page.IsStartPage)
{
sb.AppendLine($"<meta property=\"og:type\" content=\"website\">");
sb.AppendLine($"<meta property=\"og:type\" content=\"website\"/>");
}
else
{
sb.AppendLine($"<meta property=\"og:type\" content=\"article\">");
sb.AppendLine($"<meta property=\"og:type\" content=\"article\"/>");
}
sb.AppendLine($"<meta property=\"og:title\" content=\"{ OgTitle(content) }\">");
sb.AppendLine($"<meta property=\"og:title\" content=\"{ OgTitle(content) }\"/>");
if (content.OgImage != null && content.OgImage.HasValue)
{
sb.AppendLine($"<meta property=\"og:image\" content=\"{ app.AbsoluteContentUrl(content.OgImage) }\">");
sb.AppendLine($"<meta property=\"og:image\" content=\"{ app.AbsoluteContentUrl(content.OgImage) }\"/>");
}
else if (content is RoutedContentBase contentBase && contentBase.PrimaryImage != null && contentBase.PrimaryImage.HasValue)
{
// If there's no OG image specified but we have a primary image,
// default to the primary image.
sb.AppendLine($"<meta property=\"og:image\" content=\"{ app.AbsoluteContentUrl(contentBase.PrimaryImage) }\">");
sb.AppendLine($"<meta property=\"og:image\" content=\"{ app.AbsoluteContentUrl(contentBase.PrimaryImage) }\"/>");
}
if (!string.IsNullOrWhiteSpace(OgDescription(content)))
{
sb.AppendLine($"<meta property=\"og:description\" content=\"{ OgDescription(content) }\">");
sb.AppendLine($"<meta property=\"og:description\" content=\"{ OgDescription(content) }\"/>");
}
}
return new HtmlString(sb.ToString());
Expand Down

0 comments on commit b176047

Please sign in to comment.