jekyll插件不能在github上工作 [英] jekyll plugin not work on github

查看:159
本文介绍了jekyll插件不能在github上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 jekyll-plugins / weighted_pa​​ges.rb 来更改导航栏中页面的顺序aucor / jekyll-pluginsrel =nofollow> here


这个插件在我的localhost但github上运行得非常好。

我发现github主机上的导航条是空的,看起来这个插件不起作用。

我该如何解决这个问题?

我复制 weighted_pa​​ges.rb 代码如下:

 #生成site.pages的副本作为site.weighted_pa​​ges 
#页面按重量属性排序。没有指定
#重量的页面会放置在指定重量的页面之后。

模块Jekyll

类WeightedPagesGenerator<生成器
安全真正

def生成(站点)
site.config ['weighted_pa​​ges'] = site.pages.sort_by {| a |
a.data ['weight']? a.data ['weight']:site.pages.length}
结束

结束

结束

页面的前面添加 weight 属性(例如weight: 1)并在循环中使用 site.weighted_pa​​ges 而不是 site.pages

解决方案

Github页面不支持插件。从 jekyll的文档


GitHub Pages由Jekyll提供支持,但所有Pages网站都是使用--safe选项生成的,因此出于安全原因禁用了自定义插件。不幸的是,这意味着如果您部署到GitHub页面,那么您的插件将无法工作。

相同的文档页面也为您提供了解决方法:


您仍然可以使用GitHub Pages发布您的网站,但您需要在本地转换网站并推送生成的静态文件到您的GitHub存储库而不是Jekyll源文件。



I want to change the order of pages in navitation bar by using jekyll-plugins / weighted_pages.rb from here.

This plugin work very well on my localhost but github.
I find the navitation bar is empty on github host, which seems this plugin does not work.
How can I solve this problem?

I copy weighted_pages.rb code below:

# 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

Add weight attribute to the front matter of your pages (like weight: 1) and use site.weighted_pages instead of site.pages in your loops.

解决方案

Github pages does not support plugins. From jekyll's documentation:

GitHub Pages is powered by Jekyll, however all Pages sites are generated using the --safe option to disable custom plugins for security reasons. Unfortunately, this means your plugins won’t work if you’re deploying to GitHub Pages.

The same documentation page also gives you a workaround:

You can still use GitHub Pages to publish your site, but you’ll need to convert the site locally and push the generated static files to your GitHub repository instead of the Jekyll source files.

这篇关于jekyll插件不能在github上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆