Add support for likes, tags in content and micro section
parent
767683653a
commit
6d6d4baf82
16
entry.go
16
entry.go
|
@ -24,6 +24,8 @@ type Entry struct {
|
|||
slug string
|
||||
replyLink string
|
||||
replyTitle string
|
||||
likeLink string
|
||||
likeTitle string
|
||||
filename string
|
||||
location string
|
||||
token string
|
||||
|
@ -85,6 +87,9 @@ func createEntryFromValueMap(values map[string][]string) (*Entry, error) {
|
|||
if inReplyTo, ok := values["in-reply-to"]; ok {
|
||||
entry.replyLink = inReplyTo[0]
|
||||
}
|
||||
if likeOf, ok := values["like-of"]; ok {
|
||||
entry.likeLink = likeOf[0]
|
||||
}
|
||||
if token, ok := values["access_token"]; ok {
|
||||
entry.token = "Bearer " + token[0]
|
||||
}
|
||||
|
@ -114,6 +119,9 @@ func computeExtraSettings(entry *Entry) error {
|
|||
} else if strings.HasPrefix(text, "slug: ") {
|
||||
// Slug
|
||||
entry.slug = strings.TrimPrefix(text, "slug: ")
|
||||
} else if strings.HasPrefix(text, "tags: ") {
|
||||
// Tags
|
||||
entry.tags = strings.Split(strings.TrimPrefix(text, "tags: "), ",")
|
||||
} else if strings.HasPrefix(text, "link: ") {
|
||||
// Link
|
||||
entry.link = strings.TrimPrefix(text, "link: ")
|
||||
|
@ -123,6 +131,12 @@ func computeExtraSettings(entry *Entry) error {
|
|||
} else if strings.HasPrefix(text, "reply-title: ") {
|
||||
// Reply title
|
||||
entry.replyTitle = strings.TrimPrefix(text, "reply-title: ")
|
||||
} else if strings.HasPrefix(text, "like-link: ") {
|
||||
// Like link
|
||||
entry.likeLink = strings.TrimPrefix(text, "like-link: ")
|
||||
} else if strings.HasPrefix(text, "like-title: ") {
|
||||
// Like title
|
||||
entry.likeTitle = strings.TrimPrefix(text, "like-title: ")
|
||||
} else {
|
||||
_, _ = fmt.Fprintln(&filteredContent, text)
|
||||
}
|
||||
|
@ -142,7 +156,7 @@ func computeExtraSettings(entry *Entry) error {
|
|||
if entry.section == "posts" {
|
||||
entry.filename = "content/" + entry.section + "/" + entry.slug + ".md"
|
||||
entry.location = blogURL + entry.section + "/" + entry.slug
|
||||
} else if entry.section == "thoughts" || entry.section == "links" {
|
||||
} else if entry.section == "thoughts" || entry.section == "links" || entry.section == "micro" {
|
||||
entry.filename = fmt.Sprintf("content/%v/%02d/%02d/%v.md", entry.section, now.Year(), int(now.Month()), entry.slug)
|
||||
entry.location = fmt.Sprintf("%v%v/%02d/%02d/%v", blogURL, entry.section, now.Year(), int(now.Month()), entry.slug)
|
||||
} else {
|
||||
|
|
6
post.go
6
post.go
|
@ -30,6 +30,12 @@ func writeFrontMatter(entry *Entry) string {
|
|||
buff.WriteString(" title: " + entry.replyTitle + "\n")
|
||||
}
|
||||
}
|
||||
if len(entry.likeLink) > 0 {
|
||||
buff.WriteString(" like:\n link: " + entry.likeLink + "\n")
|
||||
if len(entry.likeTitle) > 0 {
|
||||
buff.WriteString(" title: " + entry.likeTitle + "\n")
|
||||
}
|
||||
}
|
||||
buff.WriteString("---\n")
|
||||
return buff.String()
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ func checkAccess(token string) (bool, error) {
|
|||
return false, errors.New("token string is empty")
|
||||
}
|
||||
// form the request to check the token
|
||||
client := &http.Client{}
|
||||
req, err := http.NewRequest("GET", indieAuthTokenUrl, nil)
|
||||
if err != nil {
|
||||
return false, errors.New("error making the request for checking token access")
|
||||
|
@ -42,7 +41,7 @@ func checkAccess(token string) (bool, error) {
|
|||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("Authorization", token)
|
||||
// send the request
|
||||
res, err := client.Do(req)
|
||||
res, err := http.Client{}.Do(req)
|
||||
if err != nil {
|
||||
return false, errors.New("error sending the request for checking token access")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue