Created
May 22, 2024 18:26
-
-
Save arumsey/d087294e29704b065ce08eaa86c1fe29 to your computer and use it in GitHub Desktop.
Using the Helix Importer createBlock function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* global WebImporter */ | |
/* Create a block of name/value pairs (eg. Metadata block) */ | |
const metadata = { | |
...WebImporter.Blocks.getMetadata(document), | |
keywords: 'keywords', | |
"Publication Date": dateFromSourceDom, | |
}; | |
const block = WebImporter.Blocks.createBlock(document, { | |
name: 'metadata', | |
cells: metadata | |
}); | |
/* Create a block from an array of elements */ | |
// Single row block with three columns | |
const items = [ | |
[document.querySelector(''), 'a string value', [...document.querySelectorAll('div.someclass p')]] | |
]; | |
const block = WebImporter.Blocks.createBlock(document, { | |
name: 'custom block name', | |
cells: items | |
}); | |
// Single row block with variant | |
const items = [ | |
[document.querySelector(''), 'a string value', [...document.querySelectorAll('div.someclass p')]] | |
]; | |
const block = WebImporter.Blocks.createBlock(document, { | |
name: 'custom block name', | |
variants: ['stretch-start'], | |
cells: items | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment