mirror of
https://github.com/glanceapp/glance.git
synced 2025-02-22 05:10:54 +01:00
Allow setting same-tab and hide-arrow on bookmark groups
This commit is contained in:
parent
f89fc2ee1d
commit
eb86c3fb79
@ -1481,6 +1481,12 @@ An array of groups which can optionally have a title and a custom color.
|
||||
| title | string | no | |
|
||||
| color | HSL | no | the primary color of the theme |
|
||||
| links | array | yes | |
|
||||
| same-tab | boolean | no | false |
|
||||
| hide-arrow | boolean | no | false |
|
||||
|
||||
> [!TIP]
|
||||
>
|
||||
> You can set `same-tab` and `hide-arrow` either on the group which will apply them to all links in that group, or on each individual link which will override the value set on the group.
|
||||
|
||||
###### Properties for each link
|
||||
| Name | Type | Required | Default |
|
||||
|
@ -10,20 +10,48 @@ type bookmarksWidget struct {
|
||||
widgetBase `yaml:",inline"`
|
||||
cachedHTML template.HTML `yaml:"-"`
|
||||
Groups []struct {
|
||||
Title string `yaml:"title"`
|
||||
Color *hslColorField `yaml:"color"`
|
||||
Links []struct {
|
||||
Title string `yaml:"title"`
|
||||
URL string `yaml:"url"`
|
||||
Icon customIconField `yaml:"icon"`
|
||||
SameTab bool `yaml:"same-tab"`
|
||||
HideArrow bool `yaml:"hide-arrow"`
|
||||
Title string `yaml:"title"`
|
||||
Color *hslColorField `yaml:"color"`
|
||||
SameTab bool `yaml:"same-tab"`
|
||||
HideArrow bool `yaml:"hide-arrow"`
|
||||
Links []struct {
|
||||
Title string `yaml:"title"`
|
||||
URL string `yaml:"url"`
|
||||
Icon customIconField `yaml:"icon"`
|
||||
// we need a pointer to bool to know whether a value was provided,
|
||||
// however there's no way to dereference a pointer in a template so
|
||||
// {{ if not .SameTab }} would return true for any non-nil pointer
|
||||
// which leaves us with no way of checking if the value is true or
|
||||
// false, hence the duplicated fields below
|
||||
SameTabRaw *bool `yaml:"same-tab"`
|
||||
SameTab bool `yaml:"-"`
|
||||
HideArrowRaw *bool `yaml:"hide-arrow"`
|
||||
HideArrow bool `yaml:"-"`
|
||||
} `yaml:"links"`
|
||||
} `yaml:"groups"`
|
||||
}
|
||||
|
||||
func (widget *bookmarksWidget) initialize() error {
|
||||
widget.withTitle("Bookmarks").withError(nil)
|
||||
|
||||
for g := range widget.Groups {
|
||||
group := &widget.Groups[g]
|
||||
for l := range group.Links {
|
||||
link := &group.Links[l]
|
||||
if link.SameTabRaw == nil {
|
||||
link.SameTab = group.SameTab
|
||||
} else {
|
||||
link.SameTab = *link.SameTabRaw
|
||||
}
|
||||
|
||||
if link.HideArrowRaw == nil {
|
||||
link.HideArrow = group.HideArrow
|
||||
} else {
|
||||
link.HideArrow = *link.HideArrowRaw
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
widget.cachedHTML = widget.renderTemplate(widget, bookmarksWidgetTemplate)
|
||||
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user