| 1 | import type { SourceSlideInfo } from '@slidev/types' |
| 2 | |
| 3 | /** |
| 4 | * If `source` is displayed in the slides, return itself. |
| 5 | * |
| 6 | * Otherwise, return the recursively first child slide imported by `source`. |
| 7 | */ |
| 8 | export function getFirstDisplayedChild(source: SourceSlideInfo) { |
| 9 | while (true) { |
| 10 | const firstChild = source.imports?.[0] |
| 11 | if (firstChild) |
| 12 | source = firstChild |
| 13 | else |
| 14 | return source |
| 15 | } |
| 16 | } |
| 17 |