sparkartgroup / gulp-markdown-to-json

Parse Markdown and YAML → compile Markdown to HTML → wrap it all up in JSON
MIT License
75 stars 14 forks source link

Combine data in single-file mode, where dirname == filename, or where filename == 'index' #7

Closed lunelson closed 8 years ago

lunelson commented 9 years ago

In the example files in your test directory, you have a file called blog.md inside the /blog directory. It would be nice if the single-file mode simply combined the data from blog.md with the child elements of that directory, which is more typical of the kind of data-structure that markdown-based content-collection systems generate. The resulting object would be like the following:

{
  "blog": {
    "slug": "blog",
    "title": "ipsum dipsum",
    "layout": "top",
    "body": "<p>From west to &quot;east&quot;!<\/p>\n",
    "posts": {
      "oakland-activist": {
        "slug": "oakland-activist",
        "title": "Epic Beard Man pop-up Oakland activist",
        "layout": "left",
        "body": "<h2 id=\"occupy\">OCCUPY<\/h2>\n<p>Fixie photo booth butcher Tumblr tattooed. Deep v bespoke accusamus, Oaklandish minim lomo denim qui pug Truffaut PBR&amp;B brunch art party put a bird on it. Typewriter put a bird on it Beer Garden, small batch velit 3 wolf moon whatever McSweeney&#39;s. Literally gluten-free XOXO hashtag irure. Quinoa bitters qui, XOXO Blue Bottle Tumblr duis squid biodiesel. Kitsch slow-carb do exercitation, four loko gluten-free garden PBR jean shorts deep v quis. Sed drinking vinegar Cosby sweater squid tote bag Temescal dolore.<\/p>\n"
      },
      "bushwick-artisan": {
        "slug": "bushwick-artisan",
        "title": "Wes Anderson pop-up Bushwick artisan",
        "layout": "centered",
        "body": "<h2 id=\"yolo\">YOLO<\/h2>\n<p>Chia quinoa meh, you probably haven&#39;t heard of them sartorial Holowaychuk pickled post-ironic. Plaid ugh vegan, Sixpoint 8-bit sartorial artisan semiotics put a bird on it Mission bicycle rights Club-Mate vinyl.<\/p>\n"
      }
    }
  }
}
pushred commented 9 years ago

Good idea! All for it, I'll tackle it soon unless you want to beat me to the punch with a PR =)

lunelson commented 9 years ago

I would if I could, but it's a bit over my head, sorry

pushred commented 8 years ago

I finally added a flattenIndex option as part of a 1.0 release (#14) that does this. If you're still using the plugin please let me know if it works as expected with your content. I'm assuming that you wanted files of the same name as their parent directory merged. I also apply the same behavior if they're named index.

lunelson commented 8 years ago

Hey, this is very cool, I haven't had a chance to try it yet but I will !