utilize new Resources capability in default module/theme
This commit is contained in:
		| @ -96,6 +96,30 @@ | ||||
|             { | ||||
|                 await InjectScripts(PageState.Page.BodyContent, ResourceLocation.Body); | ||||
|             } | ||||
|  | ||||
|             if (PageState.Page.Resources != null && PageState.Page.Resources.Exists(item => item.ResourceType == ResourceType.Script)) | ||||
|             { | ||||
|                 var interop = new Interop(JSRuntime); | ||||
|                 var scripts = new List<object>(); | ||||
|                 var inline = 0; | ||||
|                 foreach (Resource resource in PageState.Page.Resources.Where(item => item.ResourceType == ResourceType.Script && item.Level != ResourceLevel.Site)) | ||||
|                 { | ||||
|                     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()) | ||||
|                 { | ||||
|                     await interop.IncludeScripts(scripts.ToArray()); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 sbwalker
					sbwalker