forked from fluentcms/FluentCMS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fluentcms#2139 add PageHead component (fluentcms#2140)
Co-authored-by: Amir Pournasserian <[email protected]>
- Loading branch information
1 parent
9df88e7
commit a947884
Showing
11 changed files
with
59 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@namespace FluentCMS.Web.UI | ||
|
||
<title>@ViewState.Page.Title</title> | ||
|
||
<meta name="title" content="@GetSetting("MetaTitle")"> | ||
<meta name="description" content="@GetSetting("MetaDescription")"> | ||
<meta name="robots" content="@GetSetting("Robots")" /> | ||
|
||
<meta property="og:title" content="@GetSetting("MetaTitle")" /> | ||
<meta property="og:description" content="@GetSetting("MetaDescription")" /> | ||
<meta property="og:type" content="@GetSetting("OgType")" /> | ||
|
||
<meta property="twitter:title" content="@GetSetting("MetaTitle")" /> | ||
<meta property="twitter:description" content="@GetSetting("MetaDescription")" /> | ||
<meta property="twitter:type" content="@GetSetting("OgType")" /> | ||
|
||
@* Uncomment if you have images | ||
<!-- <meta property="og:image" content="@GetImageUrl(Site.SocialImage)" /> --> | ||
*@ | ||
|
||
@if (!string.IsNullOrEmpty(GetSetting("GoogleTagsId"))) | ||
{ | ||
@((MarkupString)GetGoogleTagsScript()) | ||
} | ||
|
||
@if (!string.IsNullOrEmpty(GetSetting("Head"))) | ||
{ | ||
@((MarkupString)GetSetting("Head")) | ||
} |
20 changes: 20 additions & 0 deletions
20
src/Frontend/FluentCMS.Web.UI/Components/PageHead.razor.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace FluentCMS.Web.UI; | ||
|
||
public partial class PageHead | ||
{ | ||
[Inject] | ||
private ViewState ViewState { get; set; } = default!; | ||
|
||
private string GetSetting(string key) | ||
{ | ||
ViewState.Page.Settings.TryGetValue(key, out var pageValue); | ||
ViewState.Site.Settings.TryGetValue(key, out var siteValue); | ||
|
||
return pageValue ?? siteValue ?? string.Empty; | ||
} | ||
|
||
private string GetGoogleTagsScript() | ||
{ | ||
return $"<script async src=\"https://www.googletagmanager.com/gtag/js?id={GetSetting("GoogleTagsId")}\"></script>\n<script>\n\twindow.dataLayer = window.dataLayer || [];\n\tfunction gtag(){{\n\t\tdataLayer.push(arguments);\n\t}}\ngtag('js', new Date())\ngtag('config', '{GetSetting("GoogleTagsId")}');\n</script>"; | ||
} | ||
} |
This file contains 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