get title and headcontent working again on interactive render mode

This commit is contained in:
sbwalker 2024-02-16 15:08:04 -05:00
parent 8d0aa65ab2
commit 04da989108
3 changed files with 8 additions and 28 deletions

View File

@ -6,7 +6,7 @@ namespace Oqtane.UI
{
public static class InteractiveRenderMode
{
public static IComponentRenderMode GetInteractiveRenderMode(string runtime, bool prerender)
public static IComponentRenderMode? GetInteractiveRenderMode(string runtime, bool prerender)
{
switch (runtime)
{
@ -17,7 +17,7 @@ namespace Oqtane.UI
case Runtimes.Auto:
return new InteractiveAutoRenderMode(prerender: prerender);
}
return new InteractiveServerRenderMode(prerender: prerender); // default to interactiver server
return null; // default to inherit existing render mode
}
}
}

View File

@ -53,30 +53,6 @@
{
headcontent = AddHeadContent(headcontent, PageState.Page.HeadContent);
}
if (PageState.RenderMode == RenderModes.Static)
{
string batch = DateTime.UtcNow.ToString("yyyyMMddHHmmssfff");
int count = 0;
foreach (Resource resource in PageState.Page.Resources.Where(item => item.ResourceType == ResourceType.Stylesheet && item.Level == ResourceLevel.Module))
{
// if (resource.Url.StartsWith("~"))
// {
// resource.Url = resource.Url.Replace("~", "/Themes/" + Utilities.GetTypeName(name) + "/").Replace("//", "/");
// }
if (!resource.Url.Contains("://") && PageState.Alias.BaseUrl != "" && !resource.Url.StartsWith(PageState.Alias.BaseUrl))
{
resource.Url = PageState.Alias.BaseUrl + resource.Url;
}
if (!headcontent.Contains(resource.Url, StringComparison.OrdinalIgnoreCase))
{
count++;
string id = "id=\"app-stylesheet-" + resource.Level.ToString().ToLower() + "-" + batch + "-" + count.ToString("00") + "\" ";
headcontent += "<link " + id + "rel=\"stylesheet\" href=\"" + resource.Url + "\"" + (!string.IsNullOrEmpty(resource.Integrity) ? " integrity=\"" + resource.Integrity + "\"" : "") + (!string.IsNullOrEmpty(resource.CrossOrigin) ? " crossorigin=\"" + resource.CrossOrigin + "\"" : "") + " type=\"text/css\"/>" + Environment.NewLine;
}
}
}
SiteState.Properties.HeadContent = headcontent;
DynamicComponent = builder =>

View File

@ -184,12 +184,12 @@
}
}
ManageStyleSheets(resources, alias, theme.ThemeName);
// scripts
if (_renderMode == RenderModes.Static)
{
ManageScripts(resources, alias);
}
// scripts
if (_renderMode == RenderModes.Interactive && _runtime == Runtimes.Server)
{
_reconnectScript = CreateReconnectScript();
@ -233,6 +233,10 @@
}
// create initial PageState
// page needs to be populated
// site.modules need to be populated
// user needs to be populated
_pageState = new PageState
{
Alias = alias,