diff --git a/docs/configuration.md b/docs/configuration.md index 6f161a4..610fde3 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -392,6 +392,7 @@ pages: | name | string | yes | | | slug | string | no | | | width | string | no | | +| desktop-navigation-width | string | no | | | center-vertically | boolean | no | false | | hide-desktop-navigation | boolean | no | false | | expand-mobile-page-navigation | boolean | no | false | @@ -405,9 +406,14 @@ The name of the page which gets shown in the navigation bar. The URL friendly version of the title which is used to access the page. For example if the title of the page is "RSS Feeds" you can make the page accessible via `localhost:8080/feeds` by setting the slug to `feeds`. If not defined, it will automatically be generated from the title. #### `width` -The maximum width of the page on desktop. Possible values are `slim` and `wide`. +The maximum width of the page on desktop. Possible values are `default`, `slim` and `wide`. -* default: `1600px` (when no value is specified) +#### `desktop-navigation-width` +The maximum width of the desktop navigation. Useful if you have a few pages that use a different width than the rest and don't want the navigation to jump abruptly when going to and away from those pages. Possible values are `default`, `slim` and `wide`. + +Here are the pixel equivalents for each value: + +* default: `1600px` * slim: `1100px` * wide: `1920px` diff --git a/internal/glance/config.go b/internal/glance/config.go index 95283c8..a63afff 100644 --- a/internal/glance/config.go +++ b/internal/glance/config.go @@ -64,6 +64,7 @@ type page struct { Title string `yaml:"name"` Slug string `yaml:"slug"` Width string `yaml:"width"` + DesktopNavigationWidth string `yaml:"desktop-navigation-width"` ShowMobileHeader bool `yaml:"show-mobile-header"` ExpandMobilePageNavigation bool `yaml:"expand-mobile-page-navigation"` HideDesktopNavigation bool `yaml:"hide-desktop-navigation"` @@ -435,36 +436,46 @@ func isConfigStateValid(config *config) error { } for i := range config.Pages { - if config.Pages[i].Title == "" { + page := &config.Pages[i] + + if page.Title == "" { return fmt.Errorf("page %d has no name", i+1) } - if config.Pages[i].Width != "" && (config.Pages[i].Width != "wide" && config.Pages[i].Width != "slim") { + if page.Width != "" && (page.Width != "wide" && page.Width != "slim" && page.Width != "default") { return fmt.Errorf("page %d: width can only be either wide or slim", i+1) } - if len(config.Pages[i].Columns) == 0 { + if page.DesktopNavigationWidth != "" { + if page.DesktopNavigationWidth != "wide" && page.DesktopNavigationWidth != "slim" && page.DesktopNavigationWidth != "default" { + return fmt.Errorf("page %d: desktop-navigation-width can only be either wide or slim", i+1) + } + } + + if len(page.Columns) == 0 { return fmt.Errorf("page %d has no columns", i+1) } - if config.Pages[i].Width == "slim" { - if len(config.Pages[i].Columns) > 2 { + if page.Width == "slim" { + if len(page.Columns) > 2 { return fmt.Errorf("page %d is slim and cannot have more than 2 columns", i+1) } } else { - if len(config.Pages[i].Columns) > 3 { + if len(page.Columns) > 3 { return fmt.Errorf("page %d has more than 3 columns", i+1) } } columnSizesCount := make(map[string]int) - for j := range config.Pages[i].Columns { - if config.Pages[i].Columns[j].Size != "small" && config.Pages[i].Columns[j].Size != "full" { + for j := range page.Columns { + column := &page.Columns[j] + + if column.Size != "small" && column.Size != "full" { return fmt.Errorf("column %d of page %d: size can only be either small or full", j+1, i+1) } - columnSizesCount[config.Pages[i].Columns[j].Size]++ + columnSizesCount[page.Columns[j].Size]++ } full := columnSizesCount["full"] diff --git a/internal/glance/glance.go b/internal/glance/glance.go index 5419176..ab63536 100644 --- a/internal/glance/glance.go +++ b/internal/glance/glance.go @@ -61,6 +61,14 @@ func newApplication(config *config) (*application, error) { app.slugToPage[page.Slug] = page + if page.Width == "default" { + page.Width = "" + } + + if page.DesktopNavigationWidth == "" && page.DesktopNavigationWidth != "default" { + page.DesktopNavigationWidth = page.Width + } + for c := range page.Columns { column := &page.Columns[c] diff --git a/internal/glance/static/css/site.css b/internal/glance/static/css/site.css index 4604fc6..bf87dd3 100644 --- a/internal/glance/static/css/site.css +++ b/internal/glance/static/css/site.css @@ -211,11 +211,11 @@ kbd:active { padding: 0 var(--content-bounds-padding); } -.page-width-wide .content-bounds { +.content-bounds-wide { max-width: 1920px; } -.page-width-slim .content-bounds { +.content-bounds-slim { max-width: 1100px; } diff --git a/internal/glance/templates/page.html b/internal/glance/templates/page.html index 90f7177..8e1ddae 100644 --- a/internal/glance/templates/page.html +++ b/internal/glance/templates/page.html @@ -11,7 +11,7 @@ {{ end }} -{{ define "document-root-attrs" }}class="{{ if .App.Config.Theme.Light }}light-scheme {{ end }}{{ if ne "" .Page.Width }}page-width-{{ .Page.Width }} {{ end }}{{ if .Page.CenterVertically }}page-center-vertically{{ end }}"{{ end }} +{{ define "document-root-attrs" }}class="{{ if .App.Config.Theme.Light }}light-scheme {{ end }}{{ if .Page.CenterVertically }}page-center-vertically{{ end }}"{{ end }} {{ define "document-head-after" }} {{ .App.ParsedThemeStyle }} @@ -32,7 +32,7 @@ {{ define "document-body" }}