Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Idea: Arbitrary Post meta-data #214

Open
LeifAndersen opened this issue Apr 17, 2018 · 5 comments
Open

Feature Idea: Arbitrary Post meta-data #214

LeifAndersen opened this issue Apr 17, 2018 · 5 comments

Comments

@LeifAndersen
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Owner

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
Copy link
Contributor Author

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
Copy link
Contributor

sorawee commented Nov 8, 2018

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
Copy link

toothbrush commented Jan 4, 2019

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:

  • trying to actually get an HTML comment into the final outputted page so i can regex it out of @|content| (i know i know, that's awful) – i haven't managed with Markdown or Scribble posts to get an actual HTML comment in there. I've tried splicing in !HTML-COMMENT but haven't managed, tried using @(make-comment ..) but that seems to require.. context? And of course simply putting <!-- MyKey: Val --> into Markdown or Scribble renders to &lt;!-- ... which isn't what i want.
  • trying to define a variable (with make-parameter or define or just set!) inside the post source file, which the template can read
  • Leif's suggestion of adding a new metadata type in posts.rkt although admittedly i haven't tried that because .. i believe it should be doable without modifying Frog?

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? 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants