-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathResourceHints.fusion
90 lines (87 loc) · 5.22 KB
/
ResourceHints.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**
* This prototype outputs the resource hints tags
*/
prototype(Carbon.IncludeAssets:ResourceHints) < prototype(Neos.Fusion:Component) {
dnsPrefetch = ${Configuration.setting('Carbon.IncludeAssets.ResourceHints.DnsPrefetch')}
preconnect = ${Configuration.setting('Carbon.IncludeAssets.ResourceHints.Preconnect')}
prefetch = ${Configuration.setting('Carbon.IncludeAssets.ResourceHints.Prefetch')}
preload = ${Configuration.setting('Carbon.IncludeAssets.ResourceHints.Preload')}
prerender = ${Configuration.setting('Carbon.IncludeAssets.ResourceHints.Prerender')}
modulePreload = ${Configuration.setting('Carbon.IncludeAssets.ResourceHints.ModulePreload')}
// Pass documentNodes who should be preloaded (Array, FlowQuery or a single node)
preloadNodes = null
// Pass documentNodes who should be prerendererd (Array, FlowQuery or a single node)
prerenderNodes = null
renderer = Neos.Fusion:Array {
dnsPrefetch = Neos.Fusion:Collection {
@if.set = ${Type.isArray(this.collection) && Array.length(this.collection)}
collection = ${props.dnsPrefetch}
[email protected] = ${Carbon.Array.unique(Type.isString(value) ? String.split(value, ',') : value)}
itemRenderer = afx`<link rel='dns-prefetch' href={item} />`
}
preconnect = Neos.Fusion:Collection {
@if.set = ${Type.isArray(this.collection) && Array.length(this.collection)}
collection = ${props.preconnect}
[email protected] = ${Carbon.Array.unique(Type.isString(value) ? String.split(value, ',') : value)}
itemRenderer = afx`<link rel='preconnect' href={item} />`
}
prefetch = Neos.Fusion:Collection {
@if.set = ${Type.isArray(this.collection) && Array.length(this.collection)}
collection = ${props.prefetch}
[email protected] = ${Carbon.Array.unique(Type.isString(value) ? String.split(value, ',') : value)}
itemRenderer = afx`<link rel='prefetch' href={item} />`
}
modulePreload = Neos.Fusion:Collection {
@if.set = ${Type.isArray(this.collection) && Array.length(this.collection)}
collection = ${props.modulePreload}
[email protected] = ${Carbon.Array.unique(Type.isString(value) ? String.split(value, ',') : value)}
itemRenderer = Carbon.IncludeAssets:Internal.Tag.ModulePreload {
fileObject = ${Carbon.IncludeAssets.parseFilename(item + '(modulePreload)')}
path = ${this.fileObject.filename}
}
}
preload = Neos.Fusion:Collection {
@if.set = ${Type.isArray(this.collection) && Array.length(this.collection)}
collection = ${props.preload}
[email protected] = ${Carbon.Array.unique(Type.isString(value) ? String.split(value, ',') : value)}
itemRenderer = Carbon.IncludeAssets:Internal.Tag.Preload {
fileObject = ${Carbon.IncludeAssets.parseFilename(item + '(preload)')}
path = ${this.fileObject.filename}
}
}
preloadNodes = Neos.Fusion:Collection {
@if.set = ${props.preloadNodes && Type.isArray(this.collection) && Array.length(this.collection)}
collection = ${props.preloadNodes}
collection.@process {
convertFlowQueryToArray = ${Type.instance(value, 'Neos\Eel\FlowQuery\FlowQuery') ? value.get() : value}
convertSingleToArray = ${Type.instance(value, 'Neos\ContentRepository\Domain\Model\Node') ? [value] : value}
uniqueArray = ${Carbon.Array.unique(value)}
}
itemRenderer = afx`
<link rel='preload' as='document' @if.set={Type.instance(item, 'Neos\ContentRepository\Domain\Model\Node') && documentNode != item}>
<Neos.Neos:NodeUri @path='attributes.href' node={item} absolute={true} />
</link>
`
}
prerender = Neos.Fusion:Collection {
@if.set = ${Type.isArray(this.collection) && Array.length(this.collection)}
collection = ${props.prerender}
[email protected] = ${Carbon.Array.unique(Type.isString(value) ? String.split(value, ',') : value)}
itemRenderer = afx`<link rel='prerender' href={item} />`
}
prerenderNodes = Neos.Fusion:Collection {
@if.set = ${props.prerenderNodes && Type.isArray(this.collection) && Array.length(this.collection)}
collection = ${props.prerenderNodes}
collection.@process {
convertFlowQueryToArray = ${Type.instance(value, 'Neos\Eel\FlowQuery\FlowQuery') ? value.get() : value}
convertSingleToArray = ${Type.instance(value, 'Neos\ContentRepository\Domain\Model\Node') ? [value] : value}
uniqueArray = ${Carbon.Array.unique(value)}
}
itemRenderer = afx`
<link rel='prerender' @if.set={Type.instance(item, 'Neos\ContentRepository\Domain\Model\Node') && documentNode != item}>
<Neos.Neos:NodeUri @path='attributes.href' node={item} absolute={true} />
</link>
`
}
}
}