2012-09-26 2 views
0

나는 파일을 생성하고 해당 파일에 대한 링크 문자열을 반환하는 Jekyll 플러그인 "Tags"를 작성했습니다.Jekyll 플러그인을 사용하여 _site 파일 생성

모든 것이 문제가되지 않지만 해당 파일을 _site 폴더에 직접 작성하면 제거됩니다. 이 파일을 _site 폴더 밖에두면 _site 안에 생성되지 않습니다.

_site 폴더 내에서 파일을 사용할 수 있도록 어디서 어떻게 추가해야합니까?

답변

1

이 경우 Page 클래스를 사용하고 renderwrite 메서드를 호출해야합니다.

이 내 블로그에 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 
+0

내가 지킬 :: StaticFile가 정적 파일을 생성하기 위해 확장 할 수 있습니다 발견! – roxxypoxxy

+0

@roxxypoxxy 정확히 어떻게? 그 파일을 즉시 생성합니까? 나중에 삭제됩니까? (즉, 소스 폴더에 없음) – Elchin

관련 문제