Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass RenderMode and Runtime to Head component #3848

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions Oqtane.Client/UI/Head.razor
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
private string _title = "";
private string _content = "";

[Parameter]
public string RenderMode { get; set; }

[Parameter]
public string Runtime { get; set; }

protected override void OnInitialized()
{
((INotifyPropertyChanged)SiteState.Properties).PropertyChanged += PropertyChanged;
Expand Down Expand Up @@ -49,15 +55,15 @@

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");
// }
// }
if (!string.IsNullOrEmpty(headcontent) && RenderMode == RenderModes.Interactive)
{
var index = headcontent.IndexOf("<script");
while (index >= 0)
{
headcontent = headcontent.Remove(index, headcontent.IndexOf("</script>") + 9 - index);
index = headcontent.IndexOf("<script");
}
}
return headcontent;
}

Expand Down
14 changes: 12 additions & 2 deletions Oqtane.Maui/Head.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
<DynamicComponent Type="@ComponentType"></DynamicComponent>
@using Oqtane.Shared;

<DynamicComponent Type="@ComponentType" Parameters="@Parameters"></DynamicComponent>

@code {
Type ComponentType = Type.GetType("Oqtane.UI.Head, Oqtane.Client");
Type ComponentType = Type.GetType("Oqtane.UI.Head, Oqtane.Client");
private IDictionary<string, object> Parameters { get; set; }

protected override void OnInitialized()
{
Parameters = new Dictionary<string, object>();
Parameters.Add(new KeyValuePair<string, object>("RenderMode", RenderModes.Interactive));
Parameters.Add(new KeyValuePair<string, object>("Runtime", Runtimes.Hybrid));
}
}

4 changes: 2 additions & 2 deletions Oqtane.Server/Components/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@
<link id="app-stylesheet-module" />
@if (_renderMode == RenderModes.Static)
{
<Head />
<Head RenderMode="@_renderMode" Runtime="@_runtime" />
}
else
{
<Head @rendermode="InteractiveRenderMode.GetInteractiveRenderMode(_runtime, _prerender)" />
<Head RenderMode="@_renderMode" Runtime="@_runtime" @rendermode="InteractiveRenderMode.GetInteractiveRenderMode(_runtime, _prerender)" />
}
@((MarkupString)_headResources)
</head>
Expand Down