diff --git a/Oqtane.Client/Modules/ModuleBase.cs b/Oqtane.Client/Modules/ModuleBase.cs index 24d407b9..a2da022e 100644 --- a/Oqtane.Client/Modules/ModuleBase.cs +++ b/Oqtane.Client/Modules/ModuleBase.cs @@ -96,15 +96,18 @@ namespace Oqtane.Modules var inline = 0; foreach (Resource resource in resources) { - if (!string.IsNullOrEmpty(resource.Url)) + if (string.IsNullOrEmpty(resource.RenderMode) || resource.RenderMode == RenderModes.Interactive) { - var url = (resource.Url.Contains("://")) ? resource.Url : PageState.Alias.BaseUrl + resource.Url; - scripts.Add(new { href = url, bundle = resource.Bundle ?? "", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "", es6module = resource.ES6Module, location = resource.Location.ToString().ToLower() }); - } - else - { - inline += 1; - await interop.IncludeScript(GetType().Namespace.ToLower() + inline.ToString(), "", "", "", resource.Content, resource.Location.ToString().ToLower()); + if (!string.IsNullOrEmpty(resource.Url)) + { + var url = (resource.Url.Contains("://")) ? resource.Url : PageState.Alias.BaseUrl + resource.Url; + scripts.Add(new { href = url, bundle = resource.Bundle ?? "", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "", es6module = resource.ES6Module, location = resource.Location.ToString().ToLower() }); + } + else + { + inline += 1; + await interop.IncludeScript(GetType().Namespace.ToLower() + inline.ToString(), "", "", "", resource.Content, resource.Location.ToString().ToLower()); + } } } if (scripts.Any()) diff --git a/Oqtane.Client/Themes/ThemeBase.cs b/Oqtane.Client/Themes/ThemeBase.cs index cb10bf83..f94edb68 100644 --- a/Oqtane.Client/Themes/ThemeBase.cs +++ b/Oqtane.Client/Themes/ThemeBase.cs @@ -62,15 +62,18 @@ namespace Oqtane.Themes var inline = 0; foreach (Resource resource in resources) { - if (!string.IsNullOrEmpty(resource.Url)) + if (string.IsNullOrEmpty(resource.RenderMode) || resource.RenderMode == RenderModes.Interactive) { - var url = (resource.Url.Contains("://")) ? resource.Url : PageState.Alias.BaseUrl + resource.Url; - scripts.Add(new { href = url, bundle = resource.Bundle ?? "", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "", es6module = resource.ES6Module, location = resource.Location.ToString().ToLower() }); - } - else - { - inline += 1; - await interop.IncludeScript(GetType().Namespace.ToLower() + inline.ToString(), "", "", "", resource.Content, resource.Location.ToString().ToLower()); + if (!string.IsNullOrEmpty(resource.Url)) + { + var url = (resource.Url.Contains("://")) ? resource.Url : PageState.Alias.BaseUrl + resource.Url; + scripts.Add(new { href = url, bundle = resource.Bundle ?? "", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "", es6module = resource.ES6Module, location = resource.Location.ToString().ToLower() }); + } + else + { + inline += 1; + await interop.IncludeScript(GetType().Namespace.ToLower() + inline.ToString(), "", "", "", resource.Content, resource.Location.ToString().ToLower()); + } } } if (scripts.Any()) diff --git a/Oqtane.Client/UI/SiteRouter.razor b/Oqtane.Client/UI/SiteRouter.razor index 20f536c7..d6e4cc6f 100644 --- a/Oqtane.Client/UI/SiteRouter.razor +++ b/Oqtane.Client/UI/SiteRouter.razor @@ -578,6 +578,7 @@ Location = resource.Location, ES6Module = resource.ES6Module, Content = resource.Content, + RenderMode = resource.RenderMode, Level = level, Namespace = name }); diff --git a/Oqtane.Server/Components/App.razor b/Oqtane.Server/Components/App.razor index 3301cc3b..f71dc29c 100644 --- a/Oqtane.Server/Components/App.razor +++ b/Oqtane.Server/Components/App.razor @@ -527,10 +527,11 @@ if (!string.IsNullOrEmpty(resource.Url)) { var url = (resource.Url.Contains("://")) ? resource.Url : alias.BaseUrl + resource.Url; - return ""; + ((resource.ES6Module) ? " type=\"module\"" : "") + + " src =\"" + url + "\">"; // src at end of element due to enhanced navigation patch algorithm } else { @@ -647,6 +648,7 @@ Location = resource.Location, ES6Module = resource.ES6Module, Content = resource.Content, + RenderMode = resource.RenderMode, Level = level, Namespace = name }); @@ -666,7 +668,10 @@ { count++; string id = "id=\"app-stylesheet-" + ResourceLevel.Page.ToString().ToLower() + "-" + batch + "-" + count.ToString("00") + "\" "; - _styleSheets += "" + Environment.NewLine; + _styleSheets += "" + Environment.NewLine; // href at end of element due to enhanced navigation patch algorithm } } } @@ -677,7 +682,10 @@ { foreach (var resource in resources.Where(item => item.ResourceType == ResourceType.Script)) { - AddScript(resource, alias); + if (string.IsNullOrEmpty(resource.RenderMode) || resource.RenderMode == RenderModes.Static) + { + AddScript(resource, alias); + } } } } diff --git a/Oqtane.Shared/Models/Resource.cs b/Oqtane.Shared/Models/Resource.cs index b1785834..13680a0d 100644 --- a/Oqtane.Shared/Models/Resource.cs +++ b/Oqtane.Shared/Models/Resource.cs @@ -62,6 +62,11 @@ namespace Oqtane.Models /// public string Content { get; set; } + /// + /// For Scripts this defines the render mode (default is all render modes) - not applicable to Stylesheets + /// + public string RenderMode { get; set; } + /// /// The namespace of the component that declared the resource - only used in SiteRouter ///