private ContentItem CreateContentItem( SiteStaticContentContext context, string path) { // 1: Read raw contents and meta data. Determine contents format and read it into Contents property, create RawContentItem. var rawItem = this.CreateRawItem(path); /// if a 'date' property is found in markdown file header, that date will be used instead of the date in the file name var date = rawItem.LastWriteTimeUtc; if (rawItem.Settings.ContainsKey("date")) DateTime.TryParse((string)rawItem.Settings["date"], out date); // 2: Use convert engines to get html contents and create ContentItem object foreach (var templateEngine in this._templateEngines) { if (templateEngine.CanProcess(rawItem.ContentType, "html")) { var content = templateEngine.Process(rawItem.Content, rawItem.Settings); var page = new ContentItem { FullContent = content }; var relativePath = this.EvaluateLink(context, path); page.SetHeaderSettings(rawItem.Settings); page.Settings = rawItem.Settings; page.Url = rawItem.Settings.ContainsKey("permalink") ? rawItem.Settings["permalink"] : relativePath; page.FileName = relativePath; page.Date = date; return page; } } return null; }
private static bool IsInThePast(ContentItem post) { return post.Date < DateTime.Now; }
private static bool IsPublished(ContentItem post) { return post.Published == Published.True; }
public static bool Posts(ContentItem post) { return IsPublished(post) && IsInThePast(post); }