Make the first full column the primary on mobile rather than the last

This commit is contained in:
Svilen Markov
2024-10-15 15:58:30 +01:00
parent ab0b11cc92
commit 3cfbe65855
2 changed files with 17 additions and 7 deletions

View File

@@ -75,6 +75,7 @@ type Page struct {
HideDesktopNavigation bool `yaml:"hide-desktop-navigation"`
CenterVertically bool `yaml:"center-vertically"`
Columns []Column `yaml:"columns"`
PrimaryColumnIndex int8 `yaml:"-"`
mu sync.Mutex
}
@@ -140,15 +141,24 @@ func NewApplication(config *Config) (*Application, error) {
}
for p := range config.Pages {
if config.Pages[p].Slug == "" {
config.Pages[p].Slug = titleToSlug(config.Pages[p].Title)
page := &config.Pages[p]
page.PrimaryColumnIndex = -1
if page.Slug == "" {
page.Slug = titleToSlug(page.Title)
}
app.slugToPage[config.Pages[p].Slug] = &config.Pages[p]
app.slugToPage[page.Slug] = page
for c := range config.Pages[p].Columns {
for w := range config.Pages[p].Columns[c].Widgets {
widget := config.Pages[p].Columns[c].Widgets[w]
for c := range page.Columns {
column := &page.Columns[c]
if page.PrimaryColumnIndex == -1 && column.Size == "full" {
page.PrimaryColumnIndex = int8(c)
}
for w := range column.Widgets {
widget := column.Widgets[w]
app.widgetByID[widget.GetID()] = widget
widget.SetProviders(providers)