Ejemplo n.º 1
0
        public Blog(Site site, string title, string contentPath = null, string subDirectory = null, string altTemplatePath = null) : base(site, title, contentPath, subDirectory, altTemplatePath)
        {
            blogPosts = new SortedSet <BlogPost>();
            ProcessBlogPosts(@"BlogPosts\", @"ProcessedBlogPosts\");

            LoadBlogPosts(@"ProcessedBlogPosts\", blogPosts);

            /*
             * foreach (BlogPost b in blogPosts)
             * {
             *      foreach(string s in b.Content)
             *      {
             *              AppendToProperty("#CONTENT#", new LiteralElement(String.Format("<p>{0}</p>", s)));
             *      }
             *
             * }
             */

            //Populate blog with blogpost cards and their respective pages
            foreach (BlogPost b in blogPosts)
            {
                Page postPage = site.CreatePage(b.Title, null, null, "blog");
                postPage.ContentElement = GenerateBlogCard(b);
                postPage.ContentElement.AppendToProperty("#URL#", postPage.GenerateRelativeURL(postPage));

                DataElement blogCard = GenerateBlogCard(b, 5);
                blogCard.AppendToProperty("#URL#", postPage.GenerateURL());
                ContentElement.AppendToProperty("#POSTS#", blogCard);
            }
        }