Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sorting): Fixes the return type being ordered by selector, not position in document #5

Merged
merged 1 commit into from
Jul 27, 2017

Conversation

zakhenry
Copy link
Contributor

@zakhenry zakhenry commented Jun 9, 2016

This changes the selection so the matches are returned in their natural order from the document, not the order that the selectors were listed.

Now it is possible to make multi level menus.
Example with handlebars:
Metalsmith config:

Metalsmith('test/fixture')
      .use(markdown())
      .use(headings({ selectors: ['h2', 'h3']}))
      .build();

Template:

<ul class="section table-of-contents">
      {{#each headings }}
          <li><a href="#{{ id }}">{{{ifEqual tag 'h3' '&emsp;' }}}# {{ text }}</a></li>
      {{/each}}   
</ul>

Outputs:

# Getting started
# Adding pages
 # Collections
 # Templates & Partials
 # Styles & Assets
 # Variables
# TypeDoc
# Deployment
 # Config
 # Travis CI
# Plugins

Closes #4

@oupala
Copy link

oupala commented Jun 22, 2016

Great news. I'm looking forward to see this pull request merged!

@zakhenry
Copy link
Contributor Author

@oupala if you want to use the feature now - install @xiphiaz/metalsmith-headings - it's just my unmerged fork

@mentos1386
Copy link

Would be nice to see this pull request merged.

@oupala
Copy link

oupala commented Jun 7, 2017

Thanks a lot @zakhenry !

I'm using your fork as the pull request has not been merged until now.

@oupala oupala mentioned this pull request Jul 11, 2017
@fouad fouad merged commit 7ffe0ea into metalsmith:master Jul 27, 2017
@oupala
Copy link

oupala commented Jul 28, 2017

Very good news, thanks a lot!

@zakhenry zakhenry deleted the fix/preserve-selector-order branch August 2, 2017 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

generate multi-level menus
4 participants