50 lines
1.4 KiB
Plaintext
50 lines
1.4 KiB
Plaintext
@using System.ComponentModel
|
|
@using Oqtane.Shared
|
|
@inject SiteState SiteState
|
|
|
|
@((MarkupString)title)
|
|
@((MarkupString)content)
|
|
|
|
@code {
|
|
private string title = "";
|
|
private string content = "";
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
((INotifyPropertyChanged)SiteState.Properties).PropertyChanged += PropertyChanged;
|
|
}
|
|
|
|
private void PropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
{
|
|
switch (e.PropertyName)
|
|
{
|
|
case "PageTitle":
|
|
title = "\n<title>" + SiteState.Properties.PageTitle + "</title>";
|
|
StateHasChanged();
|
|
break;
|
|
case "HeadContent":
|
|
content = RemoveScripts(SiteState.Properties.HeadContent) + "\n";
|
|
StateHasChanged();
|
|
break;
|
|
}
|
|
}
|
|
|
|
private string RemoveScripts(string headcontent)
|
|
{
|
|
if (!string.IsNullOrEmpty(headcontent))
|
|
{
|
|
var index = headcontent.IndexOf("<script");
|
|
while (index >= 0)
|
|
{
|
|
headcontent = headcontent.Remove(index, headcontent.IndexOf("</script>") + 9 - index);
|
|
index = headcontent.IndexOf("<script");
|
|
}
|
|
}
|
|
return headcontent;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
((INotifyPropertyChanged)SiteState.Properties).PropertyChanged -= PropertyChanged;
|
|
}
|
|
} |