在面向github页面的jekyll中生成类别页面

在面向github页面的jekyll中生成类别页面,jekyll,github-pages,Jekyll,Github Pages,我正在尝试使用jekyll为我的github页面博客生成分类页面。当我使用jekyllserve在本地运行时,它可以工作,因为它可以使用我的插件 使用此示例不起作用,因为github不会生成自定义插件: module Jekyll class CategoryPage < Page def initialize(site, base, dir, category) @site = site @base = base @dir = dir

我正在尝试使用jekyll为我的github页面博客生成分类页面。当我使用
jekyllserve
在本地运行时,它可以工作,因为它可以使用我的插件

使用此示例不起作用,因为github不会生成自定义插件:

module Jekyll
  class CategoryPage < Page
    def initialize(site, base, dir, category)
      @site = site
      @base = base
      @dir = dir
      @name = 'index.html'

      self.process(@name)
      self.read_yaml(File.join(base, '_layouts'), 'category_index.html')
      self.data['category'] = category

      category_title_prefix = site.config['category_title_prefix'] || 'Category: '
      self.data['title'] = "#{category_title_prefix}#{category}"
    end
  end

  class CategoryPageGenerator < Generator
    safe true

    def generate(site)
      if site.layouts.key? 'category_index'
        dir = site.config['category_dir'] || 'categories'
        site.categories.each_key do |category|
          site.pages << CategoryPage.new(site, site.source, File.join(dir, category), category)
        end
      end
    end
  end
end
模块杰基尔
类类别页<第页
def初始化(站点、基础、目录、类别)
@站点=站点
@基数=基数
@dir=dir
@name='index.html'
self.process(@name)
self.read_yaml(File.join(base,“_layouts”),“category_index.html”)
self.data['category']=类别
category_title_prefix=site.config['category_title_prefix']| |类别:'
self.data['title']=“#{category_title_prefix}#{category}”
结束
结束
类别类别页面生成器<生成器
安全真实
def生成(站点)
如果是site.layouts.key?“类别索引'
dir=site.config['category_dir']| |'categories'
site.categories.each_key do| categories|
site.pagesA)您可以编写自定义脚本(shell或Ruby或其他)以在任何地方使用生成文件。在上面的示例中,您可以将带有front matter的文件写入项目目录,而不是向站点添加新页面。例如(Ruby):

open('somepath/#{category}/index.html','w'){f|
F
open('somepath/#{category}/index.html', 'w') { |f|
  f << "---\n"
  f << "key: #{variable}\n"
  f << "---\n"
}