private static void UpdateDraftFrontMatter(IList <string> contentLines, BlogFrontMatter blogFrontMatter) { var now = DateTime.Now; var slug = blogFrontMatter.Title.ToUrlSlug(); for (var index = 0; index < contentLines.Count; index++) { var contentLine = contentLines[index]; if (contentLine.IsPermalinkLine()) { contentLines[index] = now.ToPermalink(slug); } if (contentLine.IsDateLine()) { contentLines[index] = now.ToDate(); } if (contentLine.IsDisqusIdentifierLine()) { contentLines[index] = now.ToDisqusIdentifier(); } } }
private async Task <string[]> GetUpdatedDraftFrontMatterLines(string fileInfoFullName, BlogFrontMatter draftFrontMatter) { var sourceDraftPath = Path.Combine(BlogSettings.DraftsFolder, fileInfoFullName); var draftContent = await File.ReadAllTextAsync(sourceDraftPath); var draftContentLines = draftContent.Split(Environment.NewLine); UpdateDraftFrontMatter(draftContentLines, draftFrontMatter); return(draftContentLines); }