create AppendHeadContent method to consolidate logic

This commit is contained in:
sbwalker 2023-06-14 09:37:34 -04:00
parent b21d202c7f
commit bda0943d58
4 changed files with 16 additions and 25 deletions

View File

@ -140,15 +140,8 @@
{
// include CSS
var content = "<link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/css/bootstrap.min.css\" integrity=\"sha512-t4GWSVZO1eC8BM339Xd7Uphw5s17a86tIZIj8qRxhnKub6WoyhnrxeCIMeAqBPgdZGlCcG2PrZjMc+Wr78+5Xg==\" crossorigin=\"anonymous\" type=\"text/css\"/>";
if (string.IsNullOrEmpty(SiteState.Properties.HeadContent))
{
SiteState.Properties.HeadContent = content;
}
else if (!SiteState.Properties.HeadContent.Contains(content))
{
SiteState.Properties.HeadContent += content;
}
SiteState.AppendHeadContent(content);
_togglePassword = SharedLocalizer["ShowPassword"];
_toggleConfirmPassword = SharedLocalizer["ShowPassword"];

View File

@ -281,14 +281,7 @@ namespace Oqtane.Modules
// note - only supports links and meta tags - not scripts
public void AddHeadContent(string content)
{
if (string.IsNullOrEmpty(SiteState.Properties.HeadContent))
{
SiteState.Properties.HeadContent = content;
}
else if (!SiteState.Properties.HeadContent.Contains(content))
{
SiteState.Properties.HeadContent += content;
}
SiteState.AppendHeadContent(content);
}
public void AddScript(Resource resource)

View File

@ -150,14 +150,7 @@ namespace Oqtane.Themes
// note - only supports links and meta tags - not scripts
public void AddHeadContent(string content)
{
if (string.IsNullOrEmpty(SiteState.Properties.HeadContent))
{
SiteState.Properties.HeadContent = content;
}
else if (!SiteState.Properties.HeadContent.Contains(content))
{
SiteState.Properties.HeadContent += content;
}
SiteState.AppendHeadContent(content);
}
public void AddScript(Resource resource)

View File

@ -14,5 +14,17 @@ namespace Oqtane.Shared
private dynamic _properties;
public dynamic Properties => _properties ?? (_properties = new PropertyDictionary());
public void AppendHeadContent(string content)
{
if (string.IsNullOrEmpty(Properties.HeadContent))
{
Properties.HeadContent = content;
}
else if (!Properties.HeadContent.Contains(content))
{
Properties.HeadContent += content;
}
}
}
}