Comments (11)
@mattdwen @MayhemChaos I know it's been a while, but I suppose for people in the future who have arrived here like me...
Handlebars helpers can take extra arguments (specified by name) after the default ones are provided. For more info on that, search for options.hash
on this page: http://handlebarsjs.com/expressions.html
The withSort
helper that the assemble.io guys wrote does this as well. If you provide dir="desc"
after your arguments, the loop's array will be reversed and you'll be good to go!
{{#withSort pages "data.created" dir="desc" }}
{{#unless data.exclude}}
<li><a href="{{data.url}}">{{data.title}}</a></li>
{{/unless}}
{{/withSort}}
Here is the code that does it:
https://github.com/assemble/handlebars-helpers/blob/master/lib/helpers/helpers-collections.js#L279
from assemble.io.
Refer to my 'Tip: Using the #withSort option for creating navigation menu
helpers/handlebars-helpers#200
from assemble.io.
Try putting quotes around the field...
If this works, the docs should be updated.
from assemble.io.
That seems to work, thanks for that, much appreciated!
from assemble.io.
created a new issue to update docs, since this is resolve I'll go ahead and close it
from assemble.io.
This works fine, but just sort by string, if you compare [1,2,10] output will be 1, 10, 2,
If you need to make an index, try something like a-001, a-002.
from assemble.io.
@dvera123 thanks, good to know.
from assemble.io.
Is there any way to do a desc sort on pages, without having to explicitly declare the collection in the Gruntfile?
E.g. It would be great if you could declare {{#withSort pages "data.date" desc}}
from assemble.io.
closing, we can continue discussion on handlebars-helpers repo
from assemble.io.
I tried these options to no avail..
{{#withSort pages "data.sortOrder"}}
{{#is data.section "main"}}
<li{{#is ../../page.dest this.dest}} class="active"{{/is}}>
<a href="{{relative ../../page.dest this.dest}}">{{data.menutitle}}</a>
</li>
{{/is}}
{{/withSort}}
layout: home.hbs
title: What is ZMIX?
section: main
sortOrder: a-000
---
Help?
from assemble.io.
@webercoder Great!
from assemble.io.
Related Issues (20)
- Please fix Collection documentation
- Possible Typo on Numbers Page
- Possible Typo on Strings Page
- beard aware? HOT 2
- page collections page typo
- handlebars does not support render HOT 4
- Dead link on http://assemble.io/plugins/ HOT 1
- Fix the documentation -- Quick Start -- it's not grunt anymore, it's gulp HOT 4
- http://assemble.io/helpers/helpers-dates.html Doc structure broken HOT 2
- reword joke so that it makes fun of everyone HOT 4
- {{capitalizeFirst}} has been renamed to {{capitalize}} HOT 2
- no relative url example HOT 1
- How to use custom option in loop HOT 4
- How to use Parameter in partial
- Images as working links HOT 2
- assemble doc please remove extra space HOT 1
- Markdown Fences - syntax highlighting doing nothing HOT 3
- Example in Blockquotes is incorrect HOT 1
- options.pages HOT 3
- use built-in variables HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from assemble.io.