Example #1
0
        public void GenerateBlog()
        {
            var posts     = FindWithExtension(postsPath, ".md").ToList();
            var pages     = FindWithExtension(basePath, ".html", ".liquid").ToList();
            var templates = FindWithExtension(templatesPath, ".html", ".liquid").ToList();
            var styles    = FindWithExtension(basePath, ".css").ToList();

            var input = new InputBlogContext {
                IncludePath = templatesPath, Posts = posts, Pages = pages, Templates = templates
            };
            var output = generator.Generate(input);

            if (Directory.Exists(sitePath))
            {
                Directory.Delete(sitePath, true);
            }

            Directory.CreateDirectory(sitePath);

            foreach (GeneratedPage page in output.Pages)
            {
                var path = Path.GetFullPath(page.RelativePath, sitePath);
                Directory.CreateDirectory(Path.GetDirectoryName(path));
                File.WriteAllText(path, page.Content);
            }

            foreach (RawFile file in styles)
            {
                File.WriteAllText(Path.Combine(sitePath, file.Name), file.Content);
            }
        }
Example #2
0
        public OutputBlogContext Generate(InputBlogContext context)
        {
            var pages = new List <Page>();

            pages.AddRange(ProcessPosts(context.Posts));
            pages.AddRange(ProcessPages(context.Pages));

            var generationContext = new GenerationContext {
                IncludePath = context.IncludePath, Pages = pages, Templates = context.Templates
            };
            var generatedPages = GenerateHtml(generationContext).ToList();

            return(new OutputBlogContext {
                Pages = generatedPages
            });
        }