mixu / markdown-styles

Markdown to static HTML generator and multiple CSS themes for Markdown
1.85k stars 251 forks source link

Metadata in the actual MD files #28

Open SegersIan opened 9 years ago

SegersIan commented 9 years ago

Introduction

Hi There

I am not sure if this is intended (so by design) or rather a bug. For now I have been using my custom meta data tags in my own defined layout.

Working usage

For example I have a partial header.html like

<div>
    <a href="{{myExternalLink}}">CLICK HERE</a>
</div>

My meta.json looks like

{
  "*": {
    "myExternalLink": "http://www.helloworld.com",
    "myName" : "Ian"
  }
}

This works fine as expected.

Issue

Now I would like to have within my MD file, my meta data tag myName. So if I look at my file index.md:

    Some random text, but this was written by {{myName}}

When I compile/parse now my index.md file, my value is not prefilled. It is just treated like the simple text "{{myName}}".

Question

So now my question is, was this the intention ? So that you can only use meta data tags in your html files from your layout and not within the MD files that contain the actual content. For me this is not totally clear from the documentation but it seems to work like that. If this is the expected behavior then case closed and I will live with it :)

Or can I try to resolve this using helpers or anything like that.

Foot Note

This myName meta data tag is just an example, I know with ghost render I can do more of a blog approach and such meta as author are present (if I am not mistaken). So just wanted to point it is just a fictive example.

mixu commented 9 years ago

interesting idea, but for now the expected behavior is that the handlebars tags are only applied in the HTML files. you could do this in a fork by changing the pipeline (https://github.com/mixu/markdown-styles/blob/master/lib/pipeline.js ) to read metadata before convertMd and then have a step that applies handlebars to the markdown files.

SegersIan commented 9 years ago

Thank you mixu for the feedback and especially the tip, I'll have a look at it for sure :+1: