public static void Generate(Site site) { LoadData(site); //Read templates var indexTemplate = new IndexTemplate(site); //Clean web target FileManager.Clean(site.WebPath); //Copy static: Done in calling bash script FileManager.Clone(site.StaticPath, site.WebPath); //Generate news indexTemplate["site:news"] = GenerateNews(site); var pageTemplate = new PageTemplate(site); var postTemplate = new PostTemplate(site); //Generate all files GenerateIndex(indexTemplate, site); GenerateFeed(site); foreach (Page p in site.Pages) GeneratePage(site, p, pageTemplate, indexTemplate); foreach (Post p in site.Posts) GeneratePost(site, p, postTemplate, indexTemplate); GenerateNewPostPageTemplate(site); Compressor.CompressDirectoryRecursive(site.WebPath); }
static void GeneratePage(Site site, Page p, PageTemplate pageTemplate, IndexTemplate indexTemplate) { string dirPath = Path.Combine(site.WebPath, p.Path); if (p.Path == "index/") dirPath = site.WebPath; Directory.CreateDirectory(dirPath); if (Directory.Exists(p.SourceDir)) FileManager.Clone(p.SourceDir, dirPath); var indexInstance = indexTemplate.Create(site); indexInstance["title"] = p.Title; indexInstance["tabs"] = GenerateTabs(site, p, null); indexInstance["contents"] = pageTemplate.Generate(site, p); indexInstance.Write(Path.Combine(dirPath, "index.html")); }