Permalink
Browse files

Moving to yaml-front-matter vs home rolled

  • Loading branch information...
1 parent c0ac218 commit 2e75b9ec787130fe6b6a4bdf216008975f222d88 @craveytrain committed Oct 7, 2013
Showing with 31 additions and 29 deletions.
  1. +2 −2 Gruntfile.js
  2. +2 −1 content/posts.md
  3. +3 −1 models/home.js
  4. +3 −1 models/list.js
  5. +3 −1 models/page.js
  6. +6 −8 models/post.js
  7. +2 −1 package.json
  8. +4 −1 site.yml
  9. +3 −10 tasks/render.js
  10. +1 −1 templates/home.jade
  11. +1 −1 templates/layout.jade
  12. +1 −1 templates/post.jade
View
@@ -21,7 +21,7 @@ grunt.initConfig({
render: {
content: ['content/**/*.md'],
target: 'build',
- templates: 'templates',
+ templates: 'templates'
},
jade: {
@@ -101,7 +101,7 @@ grunt.initConfig({
jshintrc: '.jshintrc'
},
grunt: ['Gruntfile.js', 'lib/**/*.js', 'tasks/**/*.js'],
- site: ['source/**/*.js']
+ site: ['source/**/*.js', 'model/**/*.js']
},
View
@@ -2,4 +2,5 @@
title: Posts
pageSlug: posts
pageType: list
----
+---
+This is the list of posts. Hi.
View
@@ -1,6 +1,8 @@
+'use strict';
+
var extend = require('extend');
module.exports = function(baseModel) {
// nothing to see here
return extend({}, baseModel);
-}
+};
View
@@ -1,6 +1,8 @@
+'use strict';
+
var extend = require('extend');
module.exports = function(baseModel) {
// nothing to see here
return extend({}, baseModel);
-}
+};
View
@@ -1,6 +1,8 @@
+'use strict';
+
var extend = require('extend');
module.exports = function(baseModel) {
// nothing to see here
return extend({}, baseModel);
-}
+};
View
@@ -1,3 +1,5 @@
+'use strict';
+
var marked = require('marked');
var excerpt = require('../lib/excerpt');
var extend = require('extend');
@@ -6,18 +8,14 @@ marked.setOptions({
gfm: true,
pedantic: false,
sanitize: true
- // callback for code highlighter
- // highlight: function(code, lang) {
- // return hl(code);
- // }
});
module.exports = function(baseModel, data) {
- var body = data.body.trim();
- data.excerpt = marked(data.excerpt || excerpt(data.body));
+ var content = data.__content.trim();
+ data.excerpt = marked(data.excerpt || excerpt(content));
- data.body = marked(body);
+ data.__content = marked(content);
return extend({}, baseModel, data);
-}
+};
View
@@ -32,7 +32,8 @@
"grunt-contrib-watch": "~0.5.3",
"grunt-contrib-connect": "~0.5.0",
"grunt-contrib-htmlmin": "~0.1.3",
- "grunt-contrib-stylus": "~0.8.0"
+ "grunt-contrib-stylus": "~0.8.0",
+ "yaml-front-matter": "~2.1.0"
},
"devDependencies": {
"highlight": "~0.2.3"
View
@@ -6,4 +6,7 @@ rss: /atom.xml
stylesheet: /css/default.css
script: /js/main.min.js
domain: craveytrain.com
-keywords: engineering, development, user interface
+keywords:
+ - engineering
+ - development
+ - user interface
View
@@ -4,8 +4,7 @@ module.exports = function(grunt) {
var extend = require('extend');
var jsYAML = require('js-yaml');
var path = require('path');
-var reYAMLFM = /^\-{3}([\w\W]+)\-{3}([\w\W]*)/;
-
+var yamlFront = require('yaml-front-matter');
var siteModel = grunt.file.readYAML('site.yml');
var baseModel = require('../models/page')(siteModel);
@@ -24,14 +23,8 @@ function determinePageType(data, page, path) {
}
var buildModel = function(page, path) {
- // split file contents into frontmatter and non
- var fileContents = reYAMLFM.exec(grunt.file.read(page));
-
- // parse out YAML
- var data = jsYAML.load(fileContents[1]);
-
- // body is the rest of the file
- data.body = fileContents[2];
+ // split file contents into YAML front matter and content
+ var data = yamlFront.loadFront(grunt.file.read(page));
if (!data.pageType) {
data.pageType = determinePageType(data, page, path);
View
@@ -4,7 +4,7 @@ block header
header.page-header(role='banner')
hgroup
h1= title
- h2=subtitle
+ h2= subtitle
block content
View
@@ -8,5 +8,5 @@ html.no-js(lang='en', dir='ltr')
include includes/nav
section.main(role='main')
block content
- != body
+ != __content
include includes/footer
View
@@ -2,4 +2,4 @@ extends layout
block content
- != body
+ != __content

0 comments on commit 2e75b9e

Please sign in to comment.