package atlas // PrependGenerated puts live nodes ahead of the authored ones on every stage // carrying the given `generate` key. Authored nodes are kept, never replaced: // they are the graceful-degradation path, and a live source that is // unavailable (no token, no network) must leave the atlas rendering exactly as // authored. Passing no nodes is therefore a no-op, not an erasure. func PrependGenerated(a *Atlas, generate string, nodes []Node) { if a == nil || len(nodes) == 0 { return } for i := range a.Stages { if a.Stages[i].Generate.Has(generate) { a.Stages[i].Nodes = append(append([]Node{}, nodes...), a.Stages[i].Nodes...) } } }