krasimir / techy

A flat file CMS based on Gulp and AbsurdJS
http://krasimir.github.io/techy
MIT License
250 stars 23 forks source link

Support YAML frontmatter #3

Closed dangoor closed 10 years ago

dangoor commented 10 years ago

I'm in the process of converting one of my sites (with a blog) from WordPress to a static site generator. I'm using Hugo now (Hugo is much faster than any other generator I've seen), but I think Techy has promise. Gulp can run pretty quickly, and I'm a JavaScript person so there would be some convenience for me in being able to customize the behavior.

Jekyll, Hugo and others support YAML frontmatter for adding variables related to a page. It looks like this:

title: My Cool Title
categories:
    - Stuff

---

## My content follows
...

This is something of a standard, and a flexible one at that. It's more convenient than <% set("title", "My Cool Title") %>, especially given that my files already have the frontmatter. Plus, when going from WordPress to one of these formats, there are already converters that generate this sort of output.

One approach would be to create a converter to convert the frontmatter to set() calls, but I think it would be cleaner to support the frontmatter directly and leave the files in that format.

krasimir commented 10 years ago

This sounds like a really nice feature. I'll use https://github.com/nodeca/js-yaml to read the YAML block. Is it ok if I follow this:

The front matter must be the first thing in the file and must take the form of valid YAML set between triple-dashed lines. I.e.:

---
layout: post
title: Blogging Like a Hacker
---
dangoor commented 10 years ago

Yeah, that's right, it's 3 dashes at the top and bottom. Also, there's this library for parsing YAML/JSON frontmatter

krasimir commented 10 years ago

That's great. I'll use this module. It will simplify the implementation.

krasimir commented 10 years ago

It's done. Here is the documentation of that feature http://krasimir.github.io/techy/docs/#using-yaml-front-matter And the test case https://github.com/krasimir/techy/tree/master/tests/using-yaml P.S. You should install the latest 0.0.24 version of Techy

dangoor commented 10 years ago

Cool! That was very fast work!