public FileContentObject(SiteObject site, FileEntry sourceFileInfo, ScriptInstance scriptInstance = null, UPath?path = null, ScriptObject preContent = null) : base(site, ContentObjectType.File, sourceFileInfo, scriptInstance, path) { if (sourceFileInfo == null) { throw new ArgumentNullException(nameof(sourceFileInfo)); } preContent?.CopyTo(this); // TODO: Make this part pluggable // Parse a standard blog text var match = ParsePostName.Match(sourceFileInfo.Name); if (match.Success) { var year = int.Parse(match.Groups[1].Value); var month = int.Parse(match.Groups[2].Value); var day = int.Parse(match.Groups[3].Value); var title = match.Groups[4].Value; Date = new DateTime(year, month, day); Slug = title; Title = StringFunctions.Capitalize(title.Replace('-', ' ')); } else { Date = DateTime.Now; } ContentType = Site.ContentTypes.GetContentType(Extension); // Extract the section of this content // section cannot be setup by the pre-content Section = Path.GetFirstDirectory(out var pathInSection); if (pathInSection.IsEmpty) { Section = string.Empty; PathInSection = Path; } else { PathInSection = pathInSection; } // Layout could have been already setup by pre-content, so we keep it in that case Layout ??= Section; // Same for the URL // Note that SetupUrl() must be called for potential HTML content or content with front matter Url ??= (string)Path; // Replicate readonly values to the Scripting object InitializeReadOnlyVariables(); }