Skip to content

How to add multiple theme support in navbar? #740

Closed
@Neutree

Description

@Neutree

Nice doc tool !!

I'm trying to make my site to support multiple theme support, like this:

_ _20190108113410

So I add script to _nvbar.md, but the script seems not work!

Any one knows how to handle it? Thanks very much

I Add the code below to _navbar.md, but the script seems can not execute!!

<div class="demo-theme-preview">
  <a data-theme="vue">vue.css</a>
  <a data-theme="dark">dark.css</a>
</div>

<style>
  .demo-theme-preview a {
    padding-right: 10px;
  }

  .demo-theme-preview a:hover {
    text-decoration: underline;
    cursor: pointer;
  }
</style>

<script>
  var preview = Docsify.dom.find('.demo-theme-preview');
  var themes = Docsify.dom.findAll('[rel="stylesheet"]');

  preview.onclick = function (e) {
    var title = e.target.getAttribute('data-theme')

    themes.forEach(function (theme) {
      
      if(theme.tilte != '' && title != null && title != ''){
        theme.disabled = theme.title != title
      }
    });
  };
</script>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions