Skip to content

Commit

Permalink
Fixing metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
fe-lix- committed Nov 23, 2023
1 parent ab268a9 commit 3e0c0d9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
1 change: 1 addition & 0 deletions tools/importer/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export default {
'nav',
'div.imagelist',
'div.cmp-experiencefragment--blog-page-cta-component',
'div.cmp-layout-manual-articles',
]);

// create the metadata block and append it to the main element
Expand Down
34 changes: 20 additions & 14 deletions tools/importer/transformers/blogArticle.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
function createBlogArticle(main, document) {
// Try to remove dts and dds that are not needed
const dts = document.querySelectorAll('dt');
const dds = document.querySelectorAll('dd');
if ( dts ) {
for( let i = 0; i < dts.length; i += 1) {
if( dts[i].textContent === 'Text')
{
const div = document.createElement('div');
div.innerHTML = dds[i].innerHTML;
dts[i].closest('article').appendChild(div);
dts[i].remove();
dds[i].remove();
}
}
// Try to remove dts and dds that are not needed
const dts = document.querySelectorAll('dt');
const dds = document.querySelectorAll('dd');
if (dts) {
for (let i = 0; i < dts.length; i += 1) {
if (dts[i].textContent === 'Byline') {
const span = document.createElement('em');
const authorText = dds[i].textContent.trim();
span.textContent = authorText;
dts[i].closest('article').appendChild(span);
}

if (dts[i].textContent === 'Text') {
const div = document.createElement('div');
div.innerHTML = dds[i].innerHTML;
dts[i].closest('article').appendChild(div);
dts[i].remove();
dds[i].remove();
}
}
}
}

export default createBlogArticle;
5 changes: 5 additions & 0 deletions tools/importer/transformers/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ const createMetadata = (main, document) => {
}
}

const author = document.querySelector('div.cmp-contentfragment__element--byline dd');
if (author) {
meta.Author = author.textContent.trim().replace(/^By /, '');
}

const block = WebImporter.Blocks.getMetadataBlock(document, meta);
main.append(block);

Expand Down

0 comments on commit 3e0c0d9

Please sign in to comment.