private List<string> ResolveCategories(SiteContext context, IDictionary<string, object> header, Page page)
{
var categories = new List<string>();
if (!IsOnlyFrontmatterCategories(context))
{
var postPath = page.File.Replace(context.SourceFolder, string.Empty);
string rawCategories = postPath.Replace(fileSystem.Path.GetFileName(page.File), string.Empty).Replace("_posts", string.Empty);
categories.AddRange(rawCategories.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries));
}
if (header.ContainsKey("categories") && header["categories"] is IEnumerable<string>)
{
categories.AddRange((IEnumerable<string>)header["categories"]);
}
else if (header.ContainsKey("category"))
{
categories.Add((string)header["category"]);
}
return categories;
}