|
3 | 3 | // eslint-disable-next-line import/no-extraneous-dependencies |
4 | 4 | import 'regenerator-runtime/runtime'; |
5 | 5 |
|
6 | | -import {createRoot} from 'react-dom/client'; |
7 | | -import {TableOfContentsFrontend} from './blocks/TableOfContents/TableOfContentsFrontend'; |
8 | | -import {HappyPointFrontend} from './blocks/HappyPoint/HappyPointFrontend'; |
9 | | -import {ColumnsFrontend} from './blocks/Columns/ColumnsFrontend'; |
10 | | -import {TopicLinkFrontend} from './blocks/TopicLink/TopicLinkFrontend'; |
11 | 6 | import {setupLightboxForImages} from './blocks/components/Lightbox/setupLightboxForImages'; |
12 | 7 | import {setupParallax} from './blocks/components/Parallax/setupParallax'; |
13 | | -import {SecondaryNavigationFrontend} from './blocks/SecondaryNavigation/SecondaryNavigationFrontend'; |
14 | | - |
15 | | -// Render React components |
16 | | -const COMPONENTS = { |
17 | | - 'planet4-blocks/submenu': TableOfContentsFrontend, |
18 | | - 'planet4-blocks/happypoint': HappyPointFrontend, |
19 | | - 'planet4-blocks/columns': ColumnsFrontend, |
20 | | - 'planet4-blocks/topic-link': TopicLinkFrontend, |
21 | | - 'planet4-blocks/secondary-navigation': SecondaryNavigationFrontend, |
22 | | -}; |
| 8 | +import {setupBlockFrontend} from './blocks/components/BlockFrontend/setupBlockFrontend'; |
23 | 9 |
|
24 | 10 | document.addEventListener('DOMContentLoaded', () => { |
25 | | - document.querySelectorAll('[data-render]').forEach( |
26 | | - blockNode => { |
27 | | - const blockName = blockNode.dataset.render; |
28 | | - if (!COMPONENTS[blockName]) { |
29 | | - return; |
30 | | - } |
31 | | - |
32 | | - const BlockFrontend = COMPONENTS[blockName]; |
33 | | - if (!BlockFrontend) { |
34 | | - return; |
35 | | - } |
36 | | - const attributes = JSON.parse(blockNode.dataset.attributes); |
37 | | - const rootElement = createRoot(blockNode); |
38 | | - rootElement.render(<BlockFrontend {...attributes.attributes} />); |
39 | | - } |
40 | | - ); |
41 | | - |
| 11 | + setupBlockFrontend(); |
42 | 12 | setupLightboxForImages(); |
43 | 13 | setupParallax(); |
44 | 14 | }); |
0 commit comments