private SDArticle GetArticle(string line, string language) { var splitted = line.Split('#'); var articleFilename = string.Empty; var articleContent = string.Empty; if (splitted.Length > 1) { if (splitted[1] == "SDDoc") { articleContent = "SDDoc"; } else { articleFilename = language.ToLower() != "default" ? string.Format("{0}.{1}", language, splitted[1]) : splitted[1]; var articleFile = _articles.SingleOrDefault(a => Path.GetFileNameWithoutExtension(a) == articleFilename); articleContent = !string.IsNullOrEmpty(articleFile) ? File.ReadAllText(articleFile) : string.Empty; } } var article = new SDArticle(); article.Title = GetNavTitle(splitted[0]); article.Filename = articleFilename; article.Content = articleContent; return(article); }
private SDArticle GetArticle(string line, Dictionary <string, string> tokens) { var splitted = line.Split('#'); SDArticle article = null; if (splitted.Length > 1) { var articleFile = GetArticleFile(splitted[1]); if (articleFile != string.Empty && Path.GetExtension(articleFile) == ".csproj" || Path.GetExtension(articleFile) == ".sln") { article = new SDDocPlaceholder { Title = GetNavTitle(splitted[0]), SolutionFile = articleFile }; } else if (articleFile != string.Empty && articleFile.StartsWith("http://") || articleFile.StartsWith("https://")) { article = new SDArticleLink { Title = GetNavTitle(splitted[0]), Link = articleFile }; } else if (articleFile != string.Empty) { var filename = Path.GetFileNameWithoutExtension(articleFile); article = new SDArticle() { Id = CreateArticleId(filename), Title = GetNavTitle(splitted[0]), Filename = filename, Content = new SDTemplate(File.ReadAllText(articleFile), tokens) }; } } else { article = new SDArticlePlaceholder { Title = GetNavTitle(splitted[0]) }; } return(article); }
private void AddArticle(SDArticle sdArticle) { if (!(sdArticle is SDArticlePlaceholder) && !(sdArticle is SDDocPlaceholder)) { var articleData = new ArticleData { Title = sdArticle.Title, Content = CommonMarkConverter.Convert(sdArticle.Content.Transform(Helper.TransformLinkToken)).ToObjectString() }; File.WriteAllText(Path.Combine(StepInput.OutputPath, "data", "articles", sdArticle.Id + ".json"), articleData.TransformText().MinifyJson()); } foreach (var article in sdArticle.Children) { AddArticle(article); } }
private SDArticle GetArticle(string line, Dictionary<string, string> tokens) { var splitted = line.Split('#'); SDArticle article = null; if (splitted.Length > 1) { var articleFile = GetArticleFile(splitted[1]); if (articleFile != string.Empty && Path.GetExtension(articleFile) == ".csproj" || Path.GetExtension(articleFile) == ".sln") { article = new SDDocPlaceholder { Title = GetNavTitle(splitted[0]), SolutionFile = articleFile }; } else if(articleFile != string.Empty && articleFile.StartsWith("http://") || articleFile.StartsWith("https://")) { article = new SDArticleLink { Title = GetNavTitle(splitted[0]), Link = articleFile }; } else if(articleFile != string.Empty) { var filename = Path.GetFileNameWithoutExtension(articleFile); article = new SDArticle() { Id = CreateArticleId(filename), Title = GetNavTitle(splitted[0]), Filename = filename, Content = new SDTemplate(File.ReadAllText(articleFile), tokens) }; } } else { article = new SDArticlePlaceholder { Title = GetNavTitle(splitted[0]) }; } return article; }