2022-05-21 13:32:18 +00:00
|
|
|
// Copyright (c) 2022 Mya Pitzeruse
|
|
|
|
// The MIT License (MIT)
|
|
|
|
|
|
|
|
package linkgroup
|
|
|
|
|
|
|
|
import (
|
2022-07-02 16:38:27 +00:00
|
|
|
"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))
|
|
|
|
}
|
|
|
|
}
|