示例#1
0
        static void Main(string[] args)
        {
            var    conv = new PascalCaseNamingConvention();
            string res  = conv.Apply("layout");

            TocEntry tocRoot = TocEntry.BuildToc("{{site.baseurl}}/", @"C:\everest-docs\docs-src\index.md");

            tocRoot.SaveForGijgoTree(@"C:\everest-docs\docs-src\toc.json");
        }
示例#2
0
        public static TocEntry BuildToc(string parentUrl, string index)
        {
            var    res         = new TocEntry();
            string indexFolder = Path.GetDirectoryName(index) + Path.DirectorySeparatorChar;

            TopicHeader header = ParseYaml(index);

            res.Title = header.Title ?? "Unknown title";
            res.Url   = parentUrl + "index.html";

            if (header.Pages != null)
            {
                foreach (var pageName in header.Pages)
                {
                    TopicHeader pageHeader = ParseYaml(indexFolder + pageName + ".md");
                    res.Childs.Add(new TocEntry
                    {
                        //Parent = res,
                        Title = pageHeader.Title ?? pageName,
                        Url   = parentUrl + pageName + ".html"
                    });
                }
            }

            if (header.Sections != null)
            {
                foreach (var sectionName in header.Sections)
                {
                    string sectionIndex = indexFolder + sectionName + Path.DirectorySeparatorChar + "index.md";
                    if (!File.Exists(sectionIndex))
                    {
                        Console.WriteLine($"WARN: Cannot find section index: {sectionIndex}");
                        continue;
                    }

                    TocEntry secEntry = BuildToc(parentUrl + sectionName + "/", sectionIndex);
                    res.Childs.Add(secEntry);
                }
            }

            return(res);
        }