Beispiel #1
0
        private async Task UpdatePostTemplateAsync()
        {
            var templatePost = new BlogPost
            {
                CreationTimeUtc   = new DateTime(2008, 9, 1),
                LastUpdateTimeUtc = new DateTime(2019, 09, 01),
                IsPublic          = false,
                Link          = "Your-Post-Link-Here",
                Title         = "Your Post Title Here",
                Visits        = 10,
                CategoryNames = new List <string> {
                    "分类名称1", "分类名称2"
                },
                TagNames = new List <string> {
                    "标签名称1", "标签名称2"
                },
                MarkdownContent = "Your Post Content Here in Markdown."
            };

            var templateMarkdown  = await new BlogPostParser(_appConfig).ToTextAsync(templatePost, false);
            var localTemplatePath = Path.Combine(_appConfig.AssetRepoLocalDir, BlogConstant.TemplatePostGitHubPath);
            await File.WriteAllTextAsync(localTemplatePath, templateMarkdown, Encoding.UTF8);

            await _gitClient.CommitAsync(_appConfig.AssetRepoLocalDir, GitHubMessageProvider.GetPostCommitMessage($"{_appConfig.AssetGitCommitUser} - update template post from server"));
        }
Beispiel #2
0
        private async Task UpdateCloudPostsAsync()
        {
            var posts = GetPosts();

            foreach (var post in posts)
            {
                var postContent = await _postParser.ToTextAsync(post, true);

                await File.WriteAllTextAsync(post.LocalFullPath, postContent, Encoding.UTF8);
            }

            await _gitClient.CommitAsync(_appConfig.AssetRepoLocalDir,
                                         GitHubMessageProvider.GetPostCommitMessage(
                                             $"{_appConfig.AssetGitCommitUser} - update posts from server"));
        }