/// <summary> /// Generates or overwrites a <see cref="MarkdownEntry"/> file /// at the specified entry root. /// </summary> /// <param name="entryRoot">the conventional directory of <see cref="MarkdownEntry"/> drafts</param> /// <param name="title">see <see cref="MarkdownEntryExtensions.WithNew11tyFrontMatter"/></param> /// <param name="inceptDate">see <see cref="MarkdownEntryExtensions.WithNew11tyFrontMatter"/></param> /// <param name="path">see <see cref="MarkdownEntryExtensions.WithNew11tyFrontMatter"/></param> /// <param name="tag">see <see cref="MarkdownEntryExtensions.WithNew11tyFrontMatter"/></param> public static MarkdownEntry GenerateEntryFor11ty(string entryRoot, string title, DateTime inceptDate, string path, string tag) { if (!Directory.Exists(entryRoot)) { throw new DirectoryNotFoundException($"The expected entry root directory, `{entryRoot ?? "[null]"}`, is not here."); } var entry = new MarkdownEntry() .WithNew11tyFrontMatter(title, inceptDate, path, tag) .WithContentHeader(); File.WriteAllText($"{entryRoot}/{entry.FrontMatter["clientId"]}.md", entry.ToFinalEdit()); return(entry); }
public void WithNew11tyFrontMatterAndContentHeaderAndTouch_Test() { //arrange var title = "Hello World!"; var inceptDate = DateTime.Now.AddSeconds(-3); var entry = new MarkdownEntry() .WithNew11tyFrontMatter(title, inceptDate, "/path/to/entry/", "entry_tag") .WithContentHeader(); //act this._testOutputHelper.WriteLine(entry.ToFinalEdit()); entry.Touch(DateTime.Now); //assert Assert.True(entry.FrontMatter.GetValue <DateTime>("modificationDate") > inceptDate); }