Exemple #1
0
func compileDirPost(src_post_dir string, info os.FileInfo, dst_posts_dir string, viewBuilder *view.Builder) (*post.BPost, error) {
	//postName := getPostNameFromRaw(info)
	srcPostDir := filepath.Join(src_post_dir, info.Name())

	// create the post object
	p, err := post.FromMarkdown(filepath.Join(srcPostDir, info.Name()+".md"))
	if err != nil {
		return nil, err
	}
	// copy the rest of the folder
	dstPostDir := filepath.Join(dst_posts_dir, p.UrlPermalink)
	if err := lpio.Copy(srcPostDir, dstPostDir, SITE_DST_PERM); err != nil {
		return nil, err
	}

	return p, generatePostHTML(p, filepath.Join(dstPostDir, "index.html"), viewBuilder)
}
Exemple #2
0
func compileSinglePost(src_post_dir string, info os.FileInfo, dst_posts_dir string, viewBuilder *view.Builder) (*post.BPost, error) {
	//postName := getPostNameFromRaw(info)

	// get the markdown filename
	postMarkdownPath := filepath.Join(src_post_dir, info.Name())

	// create the post object
	p, err := post.FromMarkdown(postMarkdownPath)
	if err != nil {
		return nil, err
	}

	// create the directory of the post
	postDir := filepath.Join(dst_posts_dir, p.UrlPermalink)
	if err := os.MkdirAll(postDir, SITE_DST_PERM); err != nil {
		return nil, err
	}
	// copy the markdown file to the directory
	if err := lpio.CopyFile(postMarkdownPath, filepath.Join(postDir, info.Name()), SITE_DST_PERM); err != nil {
		return nil, err
	}
	return p, generatePostHTML(p, filepath.Join(postDir, "index.html"), viewBuilder)
}