Skip to content

Commit

Permalink
Blog import
Browse files Browse the repository at this point in the history
  • Loading branch information
fe-lix- committed Nov 22, 2023
1 parent f41e7da commit a383252
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 deletions.
15 changes: 1 addition & 14 deletions tools/importer/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
/* eslint-disable class-methods-use-this */

// helix-importer-ui <-> node compatibility:

import {
xfTransformers, xfAsyncTransformers, transformers, postTransformers,
} from './transformers/index.js';
Expand Down Expand Up @@ -69,20 +70,6 @@ export default {
(fn) => fn.call(this, main, document, params, url),
);


// 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 === 'Image' || dts[i].textContent === 'Title' || dts[i].textContent === 'Author Bio' || dts[i].textContent === 'Tag' )
{
dts[i].remove();
dds[i].remove();
}
}
}

return main;
},

Expand Down
19 changes: 19 additions & 0 deletions tools/importer/transformers/blogArticle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function createBlogArticle(main, document) {
// Try to remove dts and dds that are not needed

Check failure on line 2 in tools/importer/transformers/blogArticle.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 2 spaces but found 4
const dts = document.querySelectorAll('dt');

Check failure on line 3 in tools/importer/transformers/blogArticle.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 2 spaces but found 4
const dds = document.querySelectorAll('dd');

Check failure on line 4 in tools/importer/transformers/blogArticle.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 2 spaces but found 4
if ( dts ) {

Check failure on line 5 in tools/importer/transformers/blogArticle.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 2 spaces but found 4

Check failure on line 5 in tools/importer/transformers/blogArticle.js

View workflow job for this annotation

GitHub Actions / build

There should be no space after this paren

Check failure on line 5 in tools/importer/transformers/blogArticle.js

View workflow job for this annotation

GitHub Actions / build

There should be no space before this paren
for( let i = 0; i < dts.length; i += 1) {

Check failure on line 6 in tools/importer/transformers/blogArticle.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 6

Check failure on line 6 in tools/importer/transformers/blogArticle.js

View workflow job for this annotation

GitHub Actions / build

Expected space(s) after "for"

Check failure on line 6 in tools/importer/transformers/blogArticle.js

View workflow job for this annotation

GitHub Actions / build

There should be no space after this paren
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;
13 changes: 13 additions & 0 deletions tools/importer/transformers/cleanBlog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function cleanBlog(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) {
dts[i].remove();
dds[i].remove();
}
}
}

export default cleanBlog;
4 changes: 4 additions & 0 deletions tools/importer/transformers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ import createHero from './hero.js';
import createMetadata from './metadata.js';
import createBold from './bold.js';
import blogBanner from './blogBanner.js';
import createBlogArticle from './blogArticle.js';
import cleanBlog from './cleanBlog.js';

export const transformers = [
createBold,
createFullLayoutSection,
blogBanner,
createBlogArticle,
// createHero,
createHomepage,
createCards,
Expand All @@ -33,4 +36,5 @@ export const preTransformers = [

export const postTransformers = [
createMetadata,
cleanBlog
];

0 comments on commit a383252

Please sign in to comment.