greghendershott / frog

Frog is a static blog generator implemented in Racket, targeting Bootstrap and able to use Pygments.
916 stars 96 forks source link

Feature Idea: Arbitrary Post meta-data #214

Open LeifAndersen opened 6 years ago

LeifAndersen commented 6 years ago

Right now a post can have metadata for Title, Date, Tags, and Authors. This is sufficient for most cases, but sometimes you want additional information in each post.

For example, lets say I wanted to enable comments, but I didn't like using disqus. I could follow this tutorial (http://hydroecology.net/using-github-to-host-blog-comments/), to use github issues to host comments for me. Unfortunately, there isn't a direct mapping from a github issue to the post itself, and so would need to be denoted for every post.

Right now, there is no good way to do that when using markdown, meaning I'd have to write all of my posts with scribble. I mean, you 'could' make a tag for the issue number, and parse that out, but that seems a bit...clunky. Instead, it might make sense to have extra meta-data be available to the post-template.html and page-template.html files, so that they can be used in formatting the page.

LeifAndersen commented 6 years ago

The bit of code is here:

     (define h
       (for/fold ([h (hash)])
                 ([s (string-split plain-text "\n")])
         (match s
           [(pregexp "^ *(.+?): *(.*?) *$" (list _ k v))
            #:when (member k '("Title" "Date" "Tags" "Authors"))
            (hash-set h k v)]
           [s (warn s) h])))

in posts.rkt. It seems like it would theoretically be as easy as just adding all meta-data info to the hash table, rather than just Title, Date`, etc.

greghendershott commented 6 years ago

That's a good idea.

The only downside that occurs to me would be the disappearance of warn. That is, today you get a helpful warning if you (say) accidentally type Author: instead of Authors:.


p.s. I don't understand this part:

Right now, there is no good way to do that when using markdown, meaning I'd have to write all of my posts with scribble.

What would be the good way, how would you do it in Scribble?

LeifAndersen commented 6 years ago

The only downside that occurs to me would be the disappearance of warn.

True. Although perhaps that could be configured in the blog's frog.rkt config file? Perhaps something like enabled meta-tags?

What would be the good way, how would you do it in Scribble?

Okay, so probably not the best way in the world. And I'd have to double check how frog renders scribble files, but what I was thinking was having the template post.html file use a parameter defined in a different racket file, and having the blog post setting that parameter.

sorawee commented 5 years ago

I always have a mixed feeling about these metadata. As I use only Scribble (never use Markdown), I would prefer to have something like Pollen's define-meta (https://docs.racket-lang.org/pollen/Core.html?q=define-meta#%28form._%28%28lib._pollen%2Fcore..rkt%29._define-meta%29%29) instead of an ad-hoc parsing. For example, (define-meta k v) for Frog could translate into the following XML:

<frog-metadata>
  <key>k</key>
  <value>v</value>
</frog-metadata>

and then you can simply search over the xexpr for frog-metadata instead of using an ad-hoc parsing and cleansing.

toothbrush commented 5 years ago

I have been playing with Frog the last few days, and i, too, would love this sort of feature. Unfortunately my Racket-fu is super rusty (much embarrassment) and so i've kinda been struggling with trying a few things:

Anyway, apologies for the helplessness, i'm going to continue poking about and see if i can make something work. Just consider this a "thank you" for making Frog and a +1 on the feature request? 😅