nfp_sites/base/article/util.mjs

30 lines
716 B
JavaScript
Raw Normal View History

2022-07-27 08:41:18 +00:00
import { parseFile } from '../file/util.mjs'
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
}
article.content = contentToBlocks(article.content)
parseMediaAndBanner(article)
2022-07-26 02:55:37 +00:00
return article
}