Skip to content

Commit

Permalink
Linting (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
fe-lix- authored Nov 23, 2023
1 parent cabd682 commit d8657df
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 44 deletions.
3 changes: 2 additions & 1 deletion tools/importer/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export default {
'div.cmp-page__skiptomaincontent',
'div#mainContent',
'div.page-header',
// Remove navigation from the beginning of blog entries as well as readmore-type teasers and blurb about 24petwatch at the end
// Remove navigation from the beginning of blog entries as well as
// readmore-type teasers and blurb about 24petwatch at the end
'nav',
'div.imagelist',
'div.cmp-experiencefragment--blog-page-cta-component',
Expand Down
27 changes: 13 additions & 14 deletions tools/importer/transformers/blogArticle.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
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 === '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;
35 changes: 13 additions & 22 deletions tools/importer/transformers/blogBanner.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
function blogBanner(main, document) {

// Banner image is in mainContent element
const bannerImage = main.querySelector('#mainContent img');

if( bannerImage ){

// Create div to hold image
const div = document.createElement('div');
const img = document.createElement('img');
const imgSrc = bannerImage.getAttribute('src');
img.setAttribute('src', imgSrc);
div.append(img);

main.prepend(div);

}

// const p = document.createElement('p');
// p.textContent = 'Hello world!';
// main.append(p);


// Banner image is in mainContent element
const bannerImage = main.querySelector('#mainContent img');

if (bannerImage) {
// Create div to hold image
const div = document.createElement('div');
const img = document.createElement('img');
const imgSrc = bannerImage.getAttribute('src');
img.setAttribute('src', imgSrc);
div.append(img);

main.prepend(div);
}
}

export default blogBanner;
4 changes: 2 additions & 2 deletions tools/importer/transformers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import createFooter from './footer.js';
import createFullLayoutSection from './fullLayoutSection.js';
import createHomepage from './homepage.js';
import createHeader from './header.js';
import createHero from './hero.js';
// import createHero from './hero.js';
import createMetadata from './metadata.js';
import createBold from './bold.js';
import blogBanner from './blogBanner.js';
Expand Down Expand Up @@ -36,5 +36,5 @@ export const preTransformers = [

export const postTransformers = [
createMetadata,
cleanBlog
cleanBlog,
];
11 changes: 6 additions & 5 deletions tools/importer/transformers/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,19 @@ const createMetadata = (main, document) => {

// Get blog article tags
const blogTags = document.querySelectorAll('div.cmp-contentfragment__element--tag > dd.cmp-contentfragment__element-value');
if( blogTags ) {
for( let i = 0; i < blogTags.length; i += 1 ) {
if (blogTags) {
for (let i = 0; i < blogTags.length; i += 1) {
meta.Tags = blogTags[i].innerHTML.replace('<br>', ' ');
}
}

// Get blog related articles
// Assumes that related articles are rendered as the only ul on the page, if not, related articles are borked for the page
// Assumes that related articles are rendered as the only ul on the page,
// if not, related articles are borked for the page
const relatedArticles = document.querySelector('ul.cmp-image-list__list');
if ( relatedArticles ){
if (relatedArticles) {
const articleLinks = relatedArticles.querySelectorAll('a.cmp-image-list__item-title-link');
for ( let i = 0; i < articleLinks.length; i += 0 ) {
for (let i = 0; i < articleLinks.length; i += 0) {
meta.Related = articleLinks[i].getAttribute('href');
}
}
Expand Down

0 comments on commit d8657df

Please sign in to comment.