Simple blogging system written in Go https://goblog.app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

26 lines
521 B

package main
import (
"os"
"path/filepath"
)
func (a *goBlog) exportMarkdownFiles(dir string) error {
posts, err := a.getPosts(&postsRequestConfig{
withoutRenderedTitle: true,
})
if err != nil {
return err
}
dir = defaultIfEmpty(dir, "export")
for _, p := range posts {
filename := filepath.Join(dir, p.Path+".md")
filedir := filepath.Dir(filename)
_ = os.MkdirAll(filedir, 0777)
err = os.WriteFile(filename, []byte(p.contentWithParams()), 0666)
if err != nil {
return err
}
}
return nil
}