Giter Site home page Giter Site logo

Comments (3)

rishabh-ink avatar rishabh-ink commented on September 10, 2024

Hi @hugodessomme, this is possible by modifying the header.html in the following way. You can see this in action in the example of the Cortana theme. Here's a snippet from Cortana's _header.html:

<% catWrappers = Array.new %>
<% @categories.each do |cat| %>
  <% catWrapperName = cat[0].split(nameScope).first %>
  <% if not catWrappers.include?(catWrapperName) %>
    <% catWrappers.push(catWrapperName) %>
  <% end %>
<% end %>

<nav class="cortana-nav">
  <ul>
    <% if file_name.include?('index.html') %>
      <li><a class="active" href="index.html">Home</a></li>
    <% else %>
      <li><a href="index.html">Home</a></li>
    <% end %>
  </ul>
  <% catWrappers.each do |wrapper| %>
    <h3><%= wrapper %></h3>
    <ul>
    <% @categories.each do |cat| %>
      <% if cat[0].include?(wrapper) %>
        <% catName = cat[0].split(nameScope).last %>
        <% if catName == title.split(nameScope).last %>
          <li><a class="active" href="<%= cat[1] %>"><%= catName %></a></li>
        <% else %>
          <li><a href="<%= cat[1] %>"><%= catName %></a></li>
        <% end %>
      <% end %>
    <% end %>
    </ul>
  <% end %>
</nav>

In your hologram_config.yml file, you'd need to add:

name_scope: ' - '

The string - is used to separate the parent and child components in the category property. Finally, in your documentation, you'd need to use it as:

/*doc
---
title: Small text
name: typography-small-text
category: Scaffolding - Typography
---
*/
...
/*doc
---
title: Strong text
name: typography-strong-text
category: Scaffolding - Typography
---
*/

As you can see, each component needs to have a parent (in the above example, Scaffolding).

You can also give the Cortana theme a try, which support nested categories out of the box.

from hologram.

hugodessomme avatar hugodessomme commented on September 10, 2024

I will give it a try! Thank you :)

from hologram.

jdcantrell avatar jdcantrell commented on September 10, 2024

Closing this, you can do what you're looking for with more ruby code in the header.html or as @rishabhsrao using the Cortana theme (which is the same method but packaged up for you)

from hologram.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.