Beispiel #1
0
        public string Run(string content, SiteContent page, RazorRenderer razorRenderer, Site site)
        {
            this.Content = content;
            this.Model = new DynamicValue(page);

            this.InitGatsbyRazorTemplate(razorRenderer, site);

            return this.ExecuteTemplate();
        }
Beispiel #2
0
        public string LayoutContent(string layoutName, string content, SiteContent page, Site site)
        {
            if (!this.layouts.ContainsKey(layoutName))
                throw new GatsbyException(string.Format("Layout \"{0}\" was not found.", layoutName));

            var layout = this.layouts[layoutName];

            try
            {
                content = layout.Run(content, page, this, site);
            }
            catch (Exception ex)
            {
                throw new GatsbyException(string.Format("Failed while rendering layout \"{0}\":\n\t{1}", layoutName, ex.Message));
            }

            if (string.IsNullOrEmpty(layout.Parent))
                return content;

            return this.LayoutContent(layout.Parent, content, page, site);
        }
Beispiel #3
0
        private void WriteContent(Config config, SiteContent page, Site site)
        {
            string content = page.Content;

            if (!string.IsNullOrEmpty(page.Layout))
                content = this.razorRenderer.LayoutContent(page.Layout, content, page, site);

            string destination = Path.Combine(config.Destination, page.Permalink);

            string directory = Path.GetDirectoryName(destination);
            if (!string.IsNullOrEmpty(directory))
                Directory.CreateDirectory(directory);

            File.WriteAllText(destination, content);
        }
Beispiel #4
0
 private void SetDefaultsForContent(SiteContent content)
 {
     if (content.LastUpdate == null)
         content.LastUpdate = content.Date;
 }
Beispiel #5
0
	public string GetUrl(SiteContent content)
	{
		return "http://zacharysnow.net/" + content.Permalink;
	}