Skip to content

Commit 7767ae0

Browse files
author
openset
committed
Update: CmdPost
1 parent c59b2c8 commit 7767ae0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

internal/post/post.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,14 @@ func runPost(cmd *base.Command, args []string) {
7979
buf.WriteString("\n---\n")
8080
buf.WriteString(fmt.Sprintf("\n## [答案](https://github.com/openset/leetcode/tree/master/problems/%s)\n", question.TitleSlug))
8181
filename := fmt.Sprintf(formatFilename, t.Format("2006-01-02"), question.TitleSlug)
82-
postType := "leetcode"
82+
oldPath := path.Join(basePath, "leetcode", filename)
83+
newPath := path.Join(basePath, "_posts", filename)
84+
base.FilePutContents(oldPath, buf.Bytes())
8385
if inPosts[questionId] {
84-
postType = "_posts"
86+
_ = os.Rename(oldPath, newPath)
87+
} else {
88+
_ = os.Remove(newPath)
8589
}
86-
base.FilePutContents(path.Join(basePath, postType, filename), buf.Bytes())
8790
}
8891
}
8992
postTags()

0 commit comments

Comments
 (0)