-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
38 lines (32 loc) · 1.02 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import dotenv from 'dotenv';
import { getArticleObjByURL } from './services/htmlService.js';
import { convertItemByTag, createEntry } from './services/contentfulService.js';
const ARTICLE = 'https://wordpress.org/documentation/article/get-started-with-wordpress/';
dotenv.config();
const main = async () => {
const articleData = await getArticleObjByURL(ARTICLE);
let content = [];
for (const item of articleData.body) {
const convertedData = await convertItemByTag(item);
if (convertedData === null) {
continue;
}
content = [...content, ...convertedData];
}
const entryBody = {
metadata: { tags: [] },
fields: {
title: { 'en-US': articleData.title },
body: {
'en-US': {
nodeType: 'document',
data: {},
content: content
}
}
}
};
const entry = await createEntry('blogPage', entryBody);
console.log(entry);
}
main();