-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathAssets.fusion
30 lines (25 loc) · 1.38 KB
/
Assets.fusion
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
* This prototype handles all assets of a location (Body || Head || BodyStart || HeadStart) set via Settings.yaml
*/
prototype(Carbon.IncludeAssets:Internal.Assets) < prototype(Neos.Fusion:Component) {
// Body || Head || BodyStart || HeadStart
location = ${null}
loadJSforCSSAsynchron = ${Configuration.setting('Carbon.IncludeAssets.LoadJSforCSSAsynchron') && this.location == 'Head'}
packages = ${Configuration.setting('Carbon.IncludeAssets.Packages')}
[email protected] = ${Type.isArray(value) ? Array.ksort(value) : value}
@if.hasLocation = ${this.location}
renderer = Neos.Fusion:Component {
inHead = ${props.location == 'Head'}
filesFromPackages = afx`
<Neos.Fusion:Loop @if.hasPackages={props.packages} items={props.packages}>
<Carbon.IncludeAssets:Internal.Package location={props.location} config={item} />
</Neos.Fusion:Loop>
`
loadAsyncCSS = ${props.loadJSforCSSAsynchron && String.indexOf(this.filesFromPackages, '<link rel="preload" as="style" onload="this.onload=null;') >= 0}
renderer = afx`
<Carbon.IncludeAssets:ResourceHints @if.head={props.inHead} />
{props.filesFromPackages}
<Carbon.IncludeAssets:File @if.render={props.loadAsyncCSS} file='resource://Carbon.IncludeAssets/Private/Templates/LoadCssAsync.js[inline]' />
`
}
}