2022-07-27 08:41:18 +00:00
|
|
|
import { parseFile } from '../file/util.mjs'
|
2022-08-02 12:34:52 +00:00
|
|
|
import { contentToBlocks, parseMediaAndBanner } from '../util.mjs'
|
2022-07-27 08:41:18 +00:00
|
|
|
|
2022-07-26 02:55:37 +00:00
|
|
|
export function parseArticles(articles) {
|
|
|
|
for (let i = 0; i < articles.length; i++) {
|
|
|
|
parseArticle(articles[i])
|
|
|
|
}
|
|
|
|
return articles
|
|
|
|
}
|
|
|
|
|
2022-07-27 08:41:18 +00:00
|
|
|
export function combineFilesWithArticles(articles, files) {
|
|
|
|
let articleMap = new Map()
|
|
|
|
|
|
|
|
articles.forEach(article => {
|
|
|
|
article.files = []
|
|
|
|
articleMap.set(article.id, article)
|
|
|
|
})
|
|
|
|
files.forEach(file => {
|
|
|
|
articleMap.get(file.id).files.push(parseFile(file))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-07-26 02:55:37 +00:00
|
|
|
export function parseArticle(article) {
|
|
|
|
if (!article) {
|
|
|
|
return null
|
|
|
|
}
|
2022-08-02 12:34:52 +00:00
|
|
|
article.content = contentToBlocks(article.content)
|
|
|
|
parseMediaAndBanner(article)
|
2022-07-26 02:55:37 +00:00
|
|
|
return article
|
|
|
|
}
|