示例#1
0
        static void GeneratePost(Site site, Post p, PostTemplate postTemplate, IndexTemplate indexTemplate)
        {
            string dirPath  = Path.Combine(site.WebPath, p.Path);
            string htmlPath = Path.Combine(dirPath, "index.html");

            Directory.CreateDirectory(dirPath);
            if (Directory.Exists(p.SourceDir))
            {
                FileManager.Clone(p.SourceDir, dirPath);
            }

            var inst = indexTemplate.Create(site);

            inst["title"]    = p.Title;
            inst["tabs"]     = GenerateTabs(site, null, p);
            inst["contents"] = postTemplate.Generate(site, p);
            inst.Write(htmlPath);
        }
示例#2
0
        static void GeneratePost(Site site, Post p, PostTemplate postTemplate, IndexTemplate indexTemplate)
        {
            string dirPath  = Path.Combine(site.WebPath, p.Path);
            string htmlPath = Path.Combine(dirPath, "index.html");

            Directory.CreateDirectory(dirPath);
            if (Directory.Exists(p.SourceDir))
            {
                FileManager.Clone(p.SourceDir, dirPath);
            }

            var inst = indexTemplate.Create(site);

            inst["title"]    = p.Title;
            inst["author"]   = p.Author;
            inst["date"]     = p.Date.ToString("yyyy-MM-dd hh:mm:ss");
            inst["tabs"]     = GenerateTabs(site, null, p);
            inst["contents"] = postTemplate.Generate(site, p);
            inst["metatags"] = Html.Raw(p.MetaTags.ToHtml(inst));
            inst.Write(htmlPath);
        }