getnikola / nikola

A static website and blog generator
https://getnikola.com/
MIT License
2.62k stars 450 forks source link

'navbar_light' parameter from base.tmpl missing in conf.py #3443

Closed k-allika closed 4 years ago

k-allika commented 4 years ago

Environment

Python Version: 3.8.3

Nikola Version: 8.1.1

Operating System: Windows 10

Part 1: Possible bug

Description: 'navbar_light' parameter available in base.tmpl but missing in conf.py

base.tmpl has the following option to select light or dark navbar themes:

<nav class="navbar navbar-expand-md static-top mb-4
% if theme_config.get('navbar_light'):
navbar-light bg-light
% else:
navbar-dark bg-dark
% endif
">

However, the option to specify this is missing in conf.py

THEME_CONFIG = {
    DEFAULT_LANG: {
        # Show the latest featured post in a large box, with the previewimage as its background.
        'featured_large': False,
        # Show the first (remaining) two featured posts in small boxes.
        'featured_small': False,
        # Show featured posts on mobile.
        'featured_on_mobile': True,
        # Show image in `featured_large` on mobile.
        # `featured_small` displays them only on desktop.
        'featured_large_image_on_mobile': True,
        # Strip HTML from featured post text.
        'featured_strip_html': False,
        # Contents of the sidebar, If empty, the sidebar is not displayed.
        'sidebar': ''
    }
}

I added the following line to the THEME_CONFIG section of my conf.py and it worked as expected. Should this be included in conf.py as default?

# navbar text colour settings. True = light, False = dark. Default: dark.
        'navbar_light': False,

Part 2

Enhancement request

An option to select navbar background to primary instead of only light or dark.

Currently, with the options above, users can select navbar-light bg-light or navbar-dark bg-dark. But most boostrap/bootswatch themes offer three navbar options, so in case I want to select the third option navbar-dark bg-primary, I'll have to manually tweak the base.tmpl. Would it be ideal to include this option in conf.py as well?

Following changes to conf.py and base.tmpl seem to work for me. May be someone can do a better coding if you decide to add this option. conf.py

THEME_CONFIG = {
    DEFAULT_LANG: {
        # Show the latest featured post in a large box, with the previewimage as its background.
        'featured_large': False,
        # Show the first (remaining) two featured posts in small boxes.
        'featured_small': False,
        # Show featured posts on mobile.
        'featured_on_mobile': True,
        # Show image in `featured_large` on mobile.
        # `featured_small` displays them only on desktop.
        'featured_large_image_on_mobile': True,
        # Strip HTML from featured post text.
        'featured_strip_html': False,
        # Contents of the sidebar, If empty, the sidebar is not displayed.
        'sidebar': '',
        # navbar text colour settings. True = light, False = dark. Default: dark.
        'navbar_light': False,
        # navbar backgound settings. Takes values 'primary', 'light' or 'dark'. Default: dark.
        'navbar_bg': ''
    }
}

base.tmpl

<!-- Menubar -->
<nav class="navbar navbar-expand-md static-top mb-4
% if theme_config.get('navbar_light'):
    navbar-light
% else:
    navbar-dark
% endif
% if theme_config.get('navbar_bg')=='primary':
    bg-primary
% elif theme_config.get('navbar_bg')=='light':
    bg-light
% else:
    bg-dark
% endif
">
Kwpolska commented 4 years ago

'navbar_light' parameter available in base.tmpl but missing in conf.py

It’s documented in the comment above THEME_CONFIG.

# Theme configuration. Fully theme-dependent. (translatable)
# Examples below are for bootblog4.
# bootblog4 supports: featured_large featured_small featured_on_mobile
#                     featured_large_image_on_mobile featured_strip_html sidebar
# bootstrap4 supports: navbar_light (defaults to False)

An option to select navbar background to primary instead of only light or dark.

We can’t add navbar_bg like you proposed, since that breaks people with navbar_light. And it would be good to support all available colors.

I created a pull request, #3444, which implements a more flexible, backwards-compatible navbar_custom_bg option.

k-allika commented 4 years ago

It’s documented in the comment above THEME_CONFIG.

Apologies. I overlooked.

I created a pull request, #3444, which implements a more flexible, backwards-compatible navbar_custom_bg option.

Thank you :-)