3 class ReadmePage < Page
4 def initialize(site, base, dir, src, idx)
13 content = File.read(src, self.merged_file_read_opts({})).each_line.to_a
15 self.data['layout'] = 'page'
16 self.data['title'] = content[0].match(/^#* ?(.*)\n$/)[1]
17 slug = self.data['title'].match(/^([^:]*):.*$/)
19 self.data['slug'] = slug[1]
21 self.data['sort'] = idx
22 self.content = content[1..content.size].join
26 class ReadmePageGenerator < Generator
30 readmes = site.config['readmes']
31 return if readmes.nil?
32 base = readmes['src_base']
33 dir = readmes['out_base']
35 for project in readmes['projects']
36 site.pages << ReadmePage.new(site, site.source, File.join(dir, project['name']), File.join(base, project['src'] ? project['src'] : project['name'], 'README.md'), idx)