private void ImportPost(WordpressPost p) { var header = new { Title = p.Title, Layout = "post", Categories = p.Categories, Tags = p.Tags }; var yamlHeader = string.Format("---\r\n{0}---\r\n\r\n", header.ToYaml()); var postContent = yamlHeader + p.Content; //todo would be nice to convert to proper md var fileName = string.Format(@"_posts\{0}-{1}.md", p.Published.ToString("yyyy-MM-dd"), p.PostName.Replace(' ', '-')); //not sure about post name fileSystem.File.WriteAllText(Path.Combine(pathToSite, fileName), postContent); }
private void ImportPost(BloggerPost post) { var header = new { title = post.Title, date = post.Published, layout = "post", categories = post.Categories, tags = post.Tags }; var yamlHeader = string.Format("---\r\n{0}---\r\n\r\n", header.ToYaml()); var postContent = yamlHeader + post.Content; string fileName = string.Format(@"{0}-{1}.md", post.Published.ToString("yyyy-MM-dd"), post.Title); //not sure about post name foreach (char c in System.IO.Path.GetInvalidFileNameChars()) { fileName = fileName.Replace(c, '_'); } // replace some valid ones too fileName = fileName.Replace(' ', '-'); fileName = fileName.Replace('\u00A0', '-'); try { fileSystem.File.WriteAllText(Path.Combine(pathToSite, Path.Combine("_posts", fileName)), postContent); } catch (Exception e) { Tracing.Info(String.Format("Failed to write out {0}", fileName)); Tracing.Debug(e.Message); } }