【发布时间】:2013-12-20 14:05:33
【问题描述】:
我想使用 jekyll-plugins / weighted_pages.rb from here 更改导航栏中的页面顺序。
这个插件在我的 localhost 但 github 上运行得很好。
我发现github主机上的导航栏是空的,看来这个插件不起作用。
我该如何解决这个问题?
我复制下面的weighted_pages.rb代码:
# Generates a copy of site.pages as site.weighted_pages
# with pages sorted by weight attribute. Pages with no
# weight specified are placed after the pages with specified weight.
module Jekyll
class WeightedPagesGenerator < Generator
safe true
def generate(site)
site.config['weighted_pages'] = site.pages.sort_by { |a|
a.data['weight'] ? a.data['weight'] : site.pages.length }
end
end
end
将weight 属性添加到pages (like weight: 1) 的前面,并在循环中使用site.weighted_pages 而不是site.pages。
【问题讨论】: