Skip to main content

A simple theme for MkDocs using using the w3.css framework and configurable color schemes

Project description

mkdocs-risonia-theme

PyPI Version PyPI downloads License: MIT

A simple theme for MkDocs. Based on this demo using the w3.css framework and configurable color schemes (inspiration here).

Demo

See a demo and documentation here

Design goals

  • Be a simple starting point for modifications.
  • Be colorful and readable.
  • Implement all features of the standard MkDocs theme (in progress).
  • Integrate some useful plugins.
  • Don't require translations.
  • Don't be obfuscated.
  • Add as little nonsense as possible.

Ugly compromises

  • To use w3css we need to add additional classes to the markdown output.
    • The good part is, while we're at it, we are also able to mark externals links.
  • The SVG icons need to be included in every page, because otherwise they can't be set to the text color.

Features

  • Light and dark mode.
  • Integration of mkdocs-static-i18n plugin.
  • Integration of mkdocs-encryptcontent-plugin.
  • Web app support.
  • Rather lightweight
  • Short (nav) and long (top panel) page titles

Installation

Install the package with pip:

pip install mkdocs-risonia-theme

Install the package from source with pip:

cd mkdocs-risonia-theme/
python setup.py sdist bdist_wheel
pip install dist/mkdocs_risonia_theme-0.1.4-py3-none-any.whl

Configuration

Enable the theme and plugins in your mkdocs.yml:

theme:
    name: risonia
    #custom_dir: theme_override/ # add static files or overrides
    #logo: img/logo.svg # if undefined a burger symbol is displayed on mobile devices
    #favicon: img/logo.ico # if undefined img/favicon.ico is used
    #manifest: manifest.json # manifest for installable webapp
    #serviceworker: service-worker.js # for webapp an empty file is sufficient
    #extlink: true # mark external links with symbol
    #extblank: true # send external links to new browser tab

plugins:
    - search: {}

    #- i18n: {...} # mkdocs-static-i18n

    - color-theme: # optional
        theme_color: '#ff6600' # primary color
        secondary_color: 'complementary' # can be a color or scheme
        #extra_css_light: # list of extra CSS for light mode
        #    - 'css/additional-light.css'
        #extra_css_dark:  # list of extra CSS for dark mode
        #    - 'css/additional-dark.css'

    - w3css-classes: {} # mandatory

    #- encryptcontent: {...} # mkdocs-encryptcontent-plugin

Overrides

The file main.html in custom_dir can be used to further customize the template:

{% extends "base.html" %}

{% block exec_script %}
<script>
  var DOMContentLoaded_fired = false;
</script>
<script id="theme">
function runWhenDOMContentLoaded() {
  document.querySelectorAll('pre code').forEach((el) => {
    hljs.highlightElement(el);
  });
  document.querySelectorAll('table').forEach(function(table) {
    if (!table.hasAttribute('Tablesort')) {
      new Tablesort(table);
      table.setAttribute('Tablesort', '');
    }
  });
}
if (DOMContentLoaded_fired) {
  runWhenDOMContentLoaded();
}
</script>
<script>
document.addEventListener('DOMContentLoaded',function(){
  DOMContentLoaded_fired=true;
  runWhenDOMContentLoaded();
});
</script>
{% endblock %}

{%- block footer_ext %}
  <p class="w3-right w3-tiny">
  {%- if i18n_config and i18n_page_file_locale %}
    <a href="{{ (i18n_page_locale + '/imprint/') | url }}">Imprint</a>
  {%- else %}
    <a href="{{ 'imprint/' | url }}">Impressum</a>
  {%- endif %}
  </p>
{%- endblock %}

{%- block top_buttons %}
    <a class="w3-button w3-theme-d1 w3-hover-theme w3-padding-small w3-right no-print" href="{{ config.repo_url }}" target="_blank">&lt;/&gt;</a> 
{%- endblock %}

Page titles

Normally nav page titles would override # heading or title meta tag. But in this theme the title meta tag will always be used for the top panel if defined.

For example define the navigation:

nav:
    - Short title: 'index.md'

And within index.md you define the long title like this:

title: Long long long title

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mkdocs-risonia-theme-0.1.4.tar.gz (23.9 kB view details)

Uploaded Source

Built Distribution

mkdocs_risonia_theme-0.1.4-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs-risonia-theme-0.1.4.tar.gz.

File metadata

  • Download URL: mkdocs-risonia-theme-0.1.4.tar.gz
  • Upload date:
  • Size: 23.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.15

File hashes

Hashes for mkdocs-risonia-theme-0.1.4.tar.gz
Algorithm Hash digest
SHA256 59bcfa598723f0e0c28d68a0d00366f320cdaf6b9b8b6c913d13947c94f858e7
MD5 f3d0225984d70af519529c43125333fe
BLAKE2b-256 da57eced355952e9f6b362dba6ef7e49e03981f617d13ca638eee92678eef5b1

See more details on using hashes here.

File details

Details for the file mkdocs_risonia_theme-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocs_risonia_theme-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c186e528a4b7849d6b0b0ee64a2b84b803cb1d63d5cb7ea6f1381ba7db207f32
MD5 b641f3b17718a4e3839562e4ab53a4ff
BLAKE2b-256 ae1c71c075771dbce9a28629791e6b8fdc2d7f4166577a1da4b521ca1690e7a2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page