Skip to content

Commit

Permalink
Merge pull request #98 from lewiseason/feature-toggles
Browse files Browse the repository at this point in the history
Add feature toggles to disable parts of the theme without overriding its files
  • Loading branch information
chrissimpkins authored Oct 26, 2020
2 parents 822b374 + 3d3db00 commit 6be8da8
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 17 deletions.
33 changes: 19 additions & 14 deletions cinder/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,25 @@
{% endblock %}
</div>

<footer class="col-md-12 text-center">
{% block footer %}
<hr>
<p>{% if config.copyright %}
<small>{{ config.copyright }}</small><br>
{% endif %}
<small>Documentation built with <a href="http://www.mkdocs.org/">MkDocs</a>.</small>
</p>

{% if page and page.meta.revision_date %}<br>
<small>Revised on: {{ page.meta.revision_date }}</small>
{% endif %}
{% endblock %}
</footer>
{% if not config.theme.disable_footer %}
<footer class="col-md-12 text-center">
{% block footer %}
{% if not config.theme.disable_footer_except_revision %}
<hr>
<p>{% if config.copyright %}
<small>{{ config.copyright }}</small><br>
{% endif %}
<small>Documentation built with <a href="http://www.mkdocs.org/">MkDocs</a>.</small>
</p>
{% endif %}

{% if page and page.meta.revision_date %}
{% if config.theme.disable_footer_except_revision %}<hr>{% else %}<br>{% endif %}
<small>Revised on: {{ page.meta.revision_date }}</small>
{% endif %}
{% endblock %}
</footer>
{% endif %}

{%- block scripts %}
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
Expand Down
8 changes: 5 additions & 3 deletions cinder/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@

<!-- Main title -->

<a class="navbar-brand" href="{{ nav.homepage.url|url }}">{{ config.site_name }}</a>
{% if not config.theme.disable_nav_site_name %}
<a class="navbar-brand" href="{{ nav.homepage.url|url }}">{{ config.site_name }}</a>
{% endif %}
</div>

<!-- Expanded navigation -->
Expand Down Expand Up @@ -46,7 +48,7 @@

<ul class="nav navbar-nav navbar-right">
{%- block search_button %}
{%- if 'search' in config['plugins'] %}
{%- if 'search' in config['plugins'] and not config.theme.disable_nav_search %}
<li>
<a href="#" data-toggle="modal" data-target="#mkdocs_search_modal">
<i class="fas fa-search"></i> Search
Expand All @@ -56,7 +58,7 @@
{%- endblock %}

{%- block next_prev %}
{%- if page and (page.next_page or page.previous_page) %}
{%- if page and (page.next_page or page.previous_page) and not config.theme.disable_nav_previous_next %}
<li {% if not page.previous_page %}class="disabled"{% endif %}>
<a rel="prev" {% if page.previous_page %}href="{{ page.previous_page.url|url }}"{% endif %}>
<i class="fas fa-arrow-left"></i> Previous
Expand Down
19 changes: 19 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,25 @@ nav:
- Home: index.md
- About: about.md</code></pre>

### Disabling Theme Features

The Cinder theme can turn off some theme features entirely in `mkdocs.yml`, for situations where you don't need these features. If this is all the customization required, it saves overriding theme files. For example:

```yml
theme:
name: cinder
# Turn off Previous/Next navigation links in the navbar
disable_nav_previous_next: true
# Turn off Search in the navbar
disable_nav_search: true
# Turn off the site_name link in the navbar
disable_nav_site_name: true
# Turn off the footer entirely
disable_footer: true
# Turn off the default footer message, but display the page revision date if it's available
disable_footer_except_revision: true
```

## Issues

If you have any issues with the theme, please report them on the Cinder repository:
Expand Down

0 comments on commit 6be8da8

Please sign in to comment.