File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- export default function decorate ( block ) {
1+ export default async function decorate ( block ) {
22 const cols = [ ...block . firstElementChild . children ] ;
33 block . classList . add ( `columns-${ cols . length } -cols` ) ;
44
Original file line number Diff line number Diff line change @@ -586,18 +586,6 @@ function decorateBlocks(main) {
586586 main . querySelectorAll ( 'div.section > div > div' ) . forEach ( decorateBlock ) ;
587587}
588588
589- /**
590- * Loads a block named 'header' into header
591- * @param {Element } header header element
592- * @returns {Promise }
593- */
594- async function loadHeader ( header ) {
595- const headerBlock = buildBlock ( 'header' , '' ) ;
596- header . append ( headerBlock ) ;
597- decorateBlock ( headerBlock ) ;
598- return loadBlock ( headerBlock ) ;
599- }
600-
601589/**
602590 * Loads a block named 'footer' into footer
603591 * @param footer footer element
@@ -677,7 +665,6 @@ export {
677665 loadBlock ,
678666 loadCSS ,
679667 loadFooter ,
680- loadHeader ,
681668 loadScript ,
682669 loadSection ,
683670 loadSections ,
Original file line number Diff line number Diff line change 88 waitForFirstImage ,
99 loadSection ,
1010 loadSections ,
11- loadCSS ,
11+ loadCSS , decorateBlock , loadBlock ,
1212} from './aem.js' ;
1313
1414/**
@@ -30,6 +30,19 @@ function buildHeroBlock(main) {
3030 }
3131}
3232
33+ function buildVideoBlocks ( main ) {
34+ const links = [ ...main . querySelectorAll ( 'a' ) ]
35+ . filter ( ( link ) => link . href . includes ( 'youtube' ) && ! link . closest ( '.block' ) ) ;
36+
37+ links . forEach ( ( link ) => {
38+ const parent = link . parentElement ;
39+ const block = buildBlock ( 'video' , { elems : [ link ] } ) ;
40+ parent . append ( block ) ;
41+ decorateBlock ( block ) ;
42+ loadBlock ( block ) ;
43+ } ) ;
44+ }
45+
3346/**
3447 * load fonts.css and set a session storage flag
3548 */
@@ -67,6 +80,7 @@ function buildAutoBlocks(main) {
6780 }
6881
6982 buildHeroBlock ( main ) ;
83+ buildVideoBlocks ( main ) ;
7084 } catch ( error ) {
7185 // eslint-disable-next-line no-console
7286 console . error ( 'Auto Blocking failed' , error ) ;
You can’t perform that action at this time.
0 commit comments