StorytellerDocGen.Topics.TopicLoader.LoadDirectory C# (CSharp) Method

LoadDirectory() public static method

public static LoadDirectory ( string directory, bool isRoot = true ) : Topic
directory string
isRoot bool
return Topic
        public static Topic LoadDirectory(string directory, bool isRoot = true)
        {
            // Needs to order based on an order.txt

            var topicFiles = FileSystem.FindFiles(directory, FileSet.Shallow("*.md")).ToArray();
            
            var topics = topicFiles.Select(x => LoadTopic(x, isRoot))
                .Union(LoadChildDirectories(directory))
                .ToArray();

            var index = topics.FirstOrDefault(x => x.IsIndex);
            if (index == null)
            {
                var splashPath = directory.AppendPath("splash.htm");
                if (File.Exists(splashPath))
                {
                    index = LoadTopic(splashPath, true);
                }
                else
                {
                    throw new Exception("Unable to find an index file for directory " + directory);
                }
            }

            var others = topics.Where(x => !x.IsIndex).ToArray();

            index.AddChildren(others);

            return index;
        }