(page)
| 59 | } |
| 60 | |
| 61 | function assertUniqueChildren(page) { |
| 62 | if (page.children.length !== new Set(page.children).size) { |
| 63 | const count = {} |
| 64 | page.children.forEach((entry) => (count[entry] = 1 + (count[entry] || 0))) |
| 65 | let msg = `${page.relativePath} has duplicates in the 'children' key.` |
| 66 | for (const [entry, times] of Object.entries(count)) { |
| 67 | if (times > 1) msg += ` '${entry}' is repeated ${times} times. ` |
| 68 | } |
| 69 | throw new Error(msg) |
| 70 | } |
| 71 | } |