repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

commit
62f92a3
parent
dc5b8a0
author
jupblb
date
2022-11-02 01:22:46 +0000 UTC
feat: support `draft` metadata property

Currently we support setting `date` into the future which will result in
the post being still URL addressable but not in our discovery feed, rss,
or the author's feed.
2 files changed,  +8, -1
M prose/scp_hooks.go
+2, -1
 1@@ -66,7 +66,8 @@ func (p *MarkdownHooks) FileMeta(data *filehandlers.PostMetaData) error {
 2 		data.PublishAt = parsedText.MetaData.PublishAt
 3 	}
 4 
 5-	data.Hidden = slices.Contains(p.Cfg.HiddenPosts, data.Filename)
 6+	isHiddenFilename := slices.Contains(p.Cfg.HiddenPosts, data.Filename)
 7+	data.Hidden = parsedText.MetaData.Hidden || isHiddenFilename
 8 
 9 	return nil
10 }
M shared/mdparser.go
+6, -0
 1@@ -34,6 +34,7 @@ type MetaData struct {
 2 	Layout      string
 3 	Image       string
 4 	ImageCard   string
 5+	Hidden      bool
 6 }
 7 
 8 type ParsedText struct {
 9@@ -56,6 +57,10 @@ func toString(obj interface{}) string {
10 	return obj.(string)
11 }
12 
13+func toBool(obj interface{}) bool {
14+	return strings.EqualFold(toString(obj), "true")
15+}
16+
17 func toLinks(obj interface{}) ([]Link, error) {
18 	links := []Link{}
19 	if obj == nil {
20@@ -224,6 +229,7 @@ func ParseText(text string, linkify Linkify) (*ParsedText, error) {
21 		parsed.Image = linkify.Create(parsed.Image[1:])
22 	}
23 	parsed.MetaData.ImageCard = toString(metaData["card"])
24+	parsed.MetaData.Hidden = toBool(metaData["draft"])
25 
26 	var publishAt *time.Time = nil
27 	var err error