123456789101112131415161718192021222324252627282930 |
- const families = {
- 9: 'depart',
- 22: 'critique',
- 63: 'echo',
- 6: 'reflexion',
- 7: 'lecture',
- 8: 'sensible',
- 23: 'kit'
- // TODO creation ?
- }
- export function formatData (data, log = false) {
- function formatSingle (text) {
- text.variant = text.families ? families[text.families[0].id] : 'black'
- for (const arrType of ['siblings', 'children', 'parents']) {
- if (arrType in text && text[arrType]) {
- formatData(text[arrType], log)
- }
- }
- }
- if (Array.isArray(data)) {
- data.forEach(formatSingle)
- } else {
- formatSingle(data)
- }
- return data
- }
|