spyysalo / annodoc

Annodoc annotation documentation support system
http://spyysalo.github.io/annodoc
MIT License
35 stars 57 forks source link

Fix to collections.js for site.collections change in Jekyll 3 #20

Open heacu opened 7 years ago

heacu commented 7 years ago

Jekyll couldn't build my site. I tracked the problem down to lib/local/collections.js, and changed it like so:

var Collections = (function(window, undefined) {
    /*
     * Listing of all the collections and documents. Generated
     * automatically by Jekyll and used e.g for the auto-linking
     * feature. Don't edit this file unless you are sure what you are
     * doing.
     */
    var listing = {
        {% for i in site.collections %}{% assign c = i %}
        "{{ c.label }}": [{% for d in c.docs %}
            {
                "title": "{{ d.title }}",
                "url":   "{{ site.baseurl }}{{ d.url }}",
            },{% endfor %}
        ],
       {% endfor %}
    };

    return {
        listing: listing,
    };
})(window);

I made this change because site.collections has changed in Jekyll 3 http://jekyllrb.com/docs/upgrading/2-to-3/#sitecollections-has-changed. My site builds again now so the change seems to have worked.

spyysalo commented 6 years ago

@torma : thanks for noting this! The compatibility hack for #16 appears to have ceased to work somewhere between jekyll 3.3.1 and 3.6.2. The error for 3.6.2 is

Liquid Exception: 1 is not a symbol nor a string in lib/local/collections.js
jekyll 3.6.2 | Error:  1 is not a symbol nor a string

I'll adopt your solution if I can't figure out a backward-compatible reformulation.