File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Sources/Ignite/Rendering/ResultBuilders Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 1111public struct DocumentBuilder {
1212 public static func buildBlock( _ components: any DocumentElement ... ) -> some HTML {
1313 Document {
14- // If no HTMLHead is provided, add a default one
15- if !components. contains ( where: { $0 is Head } ) {
16- Head ( )
14+ let ( header, components) = components. reduce (
15+ into: ( header: Head, components: [ any DocumentElement ] ) ( Head ( ) , [ ] )
16+ ) { partialResult, element in
17+ if let header = element as? Head {
18+ // In case multiple headers were provided only lat one will be used
19+ partialResult. header = header
20+ } else {
21+ partialResult. components. append ( element)
22+ }
1723 }
24+
25+ header
1826
1927 // Add all provided components
2028 for component in components {
You can’t perform that action at this time.
0 commit comments