Beispiel #1
0
 private static Node ProcessPages(DirectoryInfo path, dynamic globalSettings, string sitePath = "Home", Node parentNode = null)
 {
     var node = new DirectoryNode(path, sitePath);
       // Process each file
       foreach (var file in path.GetFiles("*.md"))
       {
     node.AddChild(new PageNode(file, globalSettings));
       }
       // Check for a syndication file
       FileInfo syndicationFile;
       if (path.TryGetFile("rss.xml", out syndicationFile))
       {
     node.AddChild(new SyndicationNode());
       }
       // Process each subdirectory
       foreach (var dir in path.GetDirectories())
       {
     var subNode = ProcessPages(dir, globalSettings, dir.Name);
     node.AddChild(subNode);
       }
       return node;
 }
Beispiel #2
0
 public void AddChild(Node node)
 {
     node.Parent = this;
       Children.Add(node);
 }
Beispiel #3
0
 private void ProcessPages(Node node)
 {
     if (node is DirectoryNode)
       {
     var directory = node as DirectoryNode;
     var destinationPath = directory.Path.FullName.Replace(_sourcePath.Subdirectory(Constants.PAGES).FullName, _outputPath.FullName);
     if (!Directory.Exists(destinationPath)) { Directory.CreateDirectory(destinationPath); }
       }
       else if (node is PageNode)
       {
     var page = node as PageNode;
     var raw = _markdown.Transform(page.GetRawContent());
     var template = Razor.GetTemplate("~/" + page.Template + ".cshtml");
     var output = Razor.ExecuteContent(template, model: new { page = page, Content = raw });
     var outputPath = page.GetOutputFileName().Replace(_sourcePath.Subdirectory(Constants.PAGES).FullName, _outputPath.FullName);
     File.WriteAllText(outputPath, output.Result);
       }
       foreach (var child in node.Children)
       {
     ProcessPages(child);
       }
 }