Pretzel.Logic.Templating.Context.SiteContextGenerator.ResolveCategories C# (CSharp) Method

ResolveCategories() private method

private ResolveCategories ( Pretzel.Logic.Templating.Context.SiteContext context, object>.IDictionary header, Pretzel.Logic.Templating.Context.Page page ) : List
context Pretzel.Logic.Templating.Context.SiteContext
header object>.IDictionary
page Pretzel.Logic.Templating.Context.Page
return List
        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;
        }