Пример #1
0
        public void RegisterMarkdownPages(string dirPath)
        {
            var di = new DirectoryInfo(dirPath);
            var markDownFiles = di.GetMatchingFiles("*.md");

            foreach (var markDownFile in markDownFiles)
            {
                var fileInfo = new FileInfo(markDownFile);
                var pageName = fileInfo.Name.SplitOnFirst('.')[0];
                var pageContents = File.ReadAllText(markDownFile);

                AddPage(new MarkdownPage(markDownFile, pageName, pageContents));
            }
        }
Пример #2
0
        public IEnumerable<MarkdownPage> FindMarkdownPages(string dirPath)
        {
            var di = new DirectoryInfo(dirPath);
            var markDownFiles = di.GetMatchingFiles("*.md")
                .Concat(di.GetMatchingFiles("*.markdown"));

            var viewPath = Path.Combine(di.FullName, "Views");
            var viewSharedPath = Path.Combine(viewPath, "Shared");

            foreach (var markDownFile in markDownFiles)
            {
                var fileInfo = new FileInfo(markDownFile);
                var pageName = fileInfo.Name.WithoutExtension();
                var pageContents = File.ReadAllText(markDownFile);

                var pageType = MarkdownPageType.ContentPage;
                if (fileInfo.FullName.StartsWithIgnoreCase(viewSharedPath))
                    pageType = MarkdownPageType.SharedViewPage;
                else if (fileInfo.FullName.StartsWithIgnoreCase(viewPath))
                    pageType = MarkdownPageType.ViewPage;

                var templatePath = GetTemplatePath(fileInfo.DirectoryName);

                yield return new MarkdownPage(this, markDownFile, pageName, pageContents, pageType) {
                    TemplatePath = templatePath,
                    LastModified = fileInfo.LastWriteTime,
                };
            }
        }