Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
leohhhn committed Feb 12, 2024
1 parent 53a7e75 commit eda9b5d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gnoblog-cli/cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func parsePost(reader io.Reader) (*post, error) {
}

p.Title, err = extractTitle(p.Body)
p.Body = removeTitle(p.Body, p.Title)
p.Body = removeTitle(string(rest), p.Title)
p.Tags = removeWhitespace(p.Tags)

if p.PublicationDate == nil {
Expand Down Expand Up @@ -52,7 +52,7 @@ func extractTitle(body string) (string, error) {
return "", fmt.Errorf("no H1 header found")
}

// removeTitle removes the first occurrence of a H1 (Title) from the body of the post
// removeTitle removes the first occurrence of the Title from the body of the post
func removeTitle(body, title string) string {
t := "# " + title + "\n"
return strings.Replace(body, t, "", 1)
Expand Down

0 comments on commit eda9b5d

Please sign in to comment.