mirror of
https://github.com/array-in-a-matrix/public-apis.git
synced 2025-04-02 11:11:50 -04:00
25 lines
732 B
JavaScript
25 lines
732 B
JavaScript
module.exports = function (tables) {
|
|
return tables.map(({ name, rows }) => {
|
|
const content = []
|
|
|
|
rows.forEach((child, i) => {
|
|
if (i === 0) return // Table header
|
|
|
|
if (child.type === 'link') {
|
|
content.push({
|
|
link: child.url,
|
|
name: child.children[0].value,
|
|
description: '',
|
|
})
|
|
} else {
|
|
const lastContentItem = content.pop()
|
|
content.push({
|
|
...lastContentItem,
|
|
description: `${lastContentItem.description} ${child.value}`,
|
|
})
|
|
}
|
|
})
|
|
|
|
return { name, rows: content }
|
|
})
|
|
}
|