emc/catalog/linkgroup/dsl.go

36 lines
604 B
Go
Raw Normal View History

2022-05-21 13:32:18 +00:00
// Copyright (c) 2022 Mya Pitzeruse
// The MIT License (MIT)
package linkgroup
import (
"code.pitz.tech/mya/emc/catalog/link"
2022-05-21 13:32:18 +00:00
)
func New(label string, options ...Option) Spec {
spec := Spec{
Label: label,
}
for _, opt := range options {
opt(&spec)
}
return spec
}
// Option defines an optional component of the spec.
type Option func(spec *Spec)
// Spec defines the elements needed to render a link group.
type Spec struct {
Label string
Links []link.Spec
}
func Link(label, url string) Option {
return func(spec *Spec) {
spec.Links = append(spec.Links, link.New(label, url))
}
}