이 경우 Page
클래스를 사용하고 render
및 write
메서드를 호출해야합니다.
이 내 블로그에 archive page를 생성하는 예입니다
module Jekyll
class ArchiveIndex < Page
def initialize(site, base, dir, periods)
@site = site
@base = base
@dir = dir
@name = 'archive.html'
self.process(@name)
self.read_yaml(File.join(base, '_layouts'), 'archive_index.html')
self.data['periods'] = periods
end
end
class ArchiveGenerator < Generator
priority :low
def generate(site)
periods = site.posts.reverse.group_by{ |c| {"month" => Date::MONTHNAMES[c.date.month], "year" => c.date.year} }
index = ArchiveIndex.new(site, site.source, '/', periods)
index.render(site.layouts, site.site_payload)
index.write(site.dest)
site.pages << index
end
end
end
내가 지킬 :: StaticFile가 정적 파일을 생성하기 위해 확장 할 수 있습니다 발견! – roxxypoxxy
@roxxypoxxy 정확히 어떻게? 그 파일을 즉시 생성합니까? 나중에 삭제됩니까? (즉, 소스 폴더에 없음) – Elchin