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

grunt-assemble withSort stops working #64

Open
maekke97 opened this issue Sep 12, 2018 · 4 comments
Open

grunt-assemble withSort stops working #64

maekke97 opened this issue Sep 12, 2018 · 4 comments

Comments

@maekke97
Copy link

Hi,
I'm not sure if this is the correct place to post this, please redirect me if I'm wrong.
We have a grunt setup to create our api documentation (http://api.meteomatics.com).
The main content pages have a handlebar header as follows:

---
title: Overview
sortOrder: 0
---

Our news blog entries like so:

---
title: "Model Output Statistics (MOS) is now available in our API" # 'to change' - Title for news blog always inside of ""
posted: "2018-04-06T12:00Z" # 'to change' - Posted Date (Format YYYY-MM-DDTHH:mmZ) UTC Time
linkforid: "2018-04-06Mos" # 'to change' - Link to scroll to this news blog, has to be unique
notInNav: true # 'keep this' - it hides the news blog in the side navigation, but it is still in the News tab
post: true # 'keep this if' - true shows this news blog, false hide it
---

Then we build our navbar using #withSort:

<ul class="nav navbar-nav">
  {{#isnt page.data.notInNav true}}
    {{#withSort  pages 'data.sortorder'}}
      {{#isnt data.notInNav true}}
        <li {{#is ../../page.dest this.dest}} class="active"{{/is}}><a href="{{filename}}" >{{data.title}}{{#is pagename "Search.html"}}<span style="float:right; margin-right: 30px;">&#128269;</span>{{/is}}</a>
        </li>
      {{/isnt}}
    {{/withSort}}
  {{else}}
    {{#withSort  pages 'data.sortorder'}}
      {{#isnt data.notInNav true}}
        <li  {{#is ../../page.title 'Available Parameters'}}
          {{#is this.dest "dest/Available-Parameters.html"}}
          class="active"
          {{/is}}
          {{/is}}><a href="{{filename}}" >{{data.title}}
        </li>
      {{/isnt}}
    {{/withSort}}
{{/isnt}}
</ul>

(I removed some content to make the example smaller)
This works all fine with up to 41 input pages. As soon as I add the 42nd (The 10th news blog entry), the sorting breaks and the navigation is in alphabetical order.

Does anyone have an Idea, what this could be?

@assemblebot
Copy link

@maekke97 Thanks for the issue! If you're reporting a bug, please be sure to include:

  • The version of assemble you are using.
  • Your assemblefile.js (This can be in a gist)
  • The commandline output. (Screenshot or gist is fine)
  • What you expected to happen instead.

@doowb
Copy link
Member

doowb commented Sep 12, 2018

One thing that I noticed is that in the yaml frontmatter the property is sortOrder (with a capital O) but the template uses data.sortorder (with a lowercase o). Since you say that this works up to 41 items, then I'm assuming that may have been a typo in the issue.

If it was a typo and that's not causing an issue, I'm not exactly sure what might be going on. It would help if you could share the repository or at least a list of all of the pages with their sortOrder properties (the sorting might be comparing strings instead of numbers). Also, if you could provide more of the information requested by the assemblebot, it would be helpful.

@maekke97
Copy link
Author

maekke97 commented Sep 12, 2018

Hi, thanks for looking into this.
It actually is a typo that has no effect. (I just checked that it does not matter if you have )

I'm not able to share the repo, as it lies on our privat company server, sorry.
What I can share: (please let me know if you need more infos)

$ grunt -V
grunt-cli v1.2.0
grunt v0.4.5
$ npm -v
6.1.0
$ node -v
v8.11.4
$ npm list grunt-assemble
[email protected]
└── [email protected] 

The project structure:

|-templates/
|--includes/
|---allnewsblog.hbs -> sortorder: -1
|---head.hbs -> No sortorder field
|---navbar.hbs -> No sortorder field
|---newssideblog.hbs -> No sortorder field
|--AP-Agricultural-Parameters.hbs -> sortorder: 3.5
|--AP-Atmospheric-Pollution.hbs -> sortorder: 3.5
|--AP-XYZ (there are 16 more) all -> sortorder: 3.5
|--API-Request.hbs -> sortorder: 4
|--API-Response.hbs -> sortorder: 5
|--Appendix.hbs -> sortorder: 9
|--Avaliable-Parameters.hbs -> sortorder: 3.4
|--DataConnectors.hbs -> sortorder: 3
|--FAQ.hbs -> sortorder: 8.5
|--GettingStarted.hbs -> sortorder: 2
|--Imprint.hbs -> sortorder: 11
|--index.hbs -> sortorder: 0
|--News.hbs -> sortorder: -1
|--Overview.hbs -> sortorder: 0
|--Search.hbs -> sortorder: 1
|--WFS-Interface.hbs -> sortorder: 7
|--WMS-Interface.hbs -> sortorder: 6
|-content/
|--news/
|---2018-04-06-Mos.md -> posted: "2018-04-06T12:00Z"
|---2018-04-06-News.md -> posted: "2018-04-06T09:00Z"
|---2018-04-06-Zip.md -> posted: "2018-04-06T13:00Z"
|---2018-04-11-Satellite.md -> posted: "2018-04-11T09:00Z"
|---2018-04-23-WfsStations.md -> posted: "2018-04-23T16:00Z"
|---2018-06-06-Hail.md -> posted: "2018-06-06T20:00Z"
|---2018-07-30-GoogleSpreadSheet.md -> posted: "2018-07-30T11:00Z"
|---2018-07-31-Tableau.md -> posted: "2018-07-31T11:00Z"
|---2018-08-01-Qlik.md -> posted: "2018-08-01T11:00Z"
|---2018-09-11-Cesium.md -> posted: "2018-09-11T09:00Z"
|--AP-Agricultural-Parameters.md
|--... (One .md for each .hbs in templates)
|-Gruntfile.js (see below)

Gruntfile.js:

grunt.initConfig({
        assemble: {
            options: {
              collections: [{
                  name: 'post',
                  sortby: 'posted',
                  sortorder: 'descending'
                }],
                flatten: true,
                partials: ['templates/includes/*.hbs'],
                layoutdir: 'templates/layouts',
                layout: 'default.hbs'
            },
            site: {
                files: {
                    'dest/': ['templates/*.hbs','content/news/*.md']
                }
            }
        },
...

Grunt assembles all without error. The result with only 9 news blog files can be seen here: http://api.meteomatics.com/
(We removed the 2018-04-06-News.md file from the productive tree for now)
When I compile locally with the file, the Menu is the following:
bildschirmfoto 2018-09-12 um 16 05 05
Lower part:
bildschirmfoto 2018-09-12 um 16 13 26

@doowb
Copy link
Member

doowb commented Sep 12, 2018

Thanks for the additional information, I'll try to look at this soon.

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

No branches or pull requests

3 participants