Skip to content
Browse files

Merge pull request #269 from benbalter/frontmatter-all-the-things

Detect YAML frontmatter on any file, regardless of type
  • Loading branch information...
2 parents 54817eb + cac8038 commit b2ea449343dae55febbd980fd273fba01d50d8b0 @dhcole dhcole committed Mar 25, 2013
Showing with 7 additions and 2 deletions.
  1. +2 −2 _includes/model.js
  2. +5 −0 _includes/util.js
View
4 _includes/model.js
@@ -427,7 +427,7 @@ function loadPost(user, repo, branch, path, file, cb) {
return !!(app.state.permissions && app.state.permissions.push);
}
- if (!_.jekyll(path, file)) return {
+ if (!_.hasMetadata(content)) return {
raw_metadata: "",
content: content,
published: false,
@@ -447,7 +447,7 @@ function loadPost(user, repo, branch, path, file, cb) {
cb(err, _.extend(post, {
"sha": commit,
"markdown": _.markdown(file),
- "jekyll": _.jekyll(path, file),
+ "jekyll": _.hasMetadata(data),
"repo": repo,
"path": path,
"file": file,
View
5 _includes/util.js
@@ -83,6 +83,11 @@ _.jekyll = function(path, file) {
return !!(path.match('_posts') && _.markdown(file));
};
+// check if a given file has YAML frontmater
+// -------
+_.hasMetadata = function(content) {
+ return content.match( /^(---\n)((.|\n)*?)\n---\n?/ );
+}
// Extract file extension
// -------

0 comments on commit b2ea449

Please sign in to comment.
Something went wrong with that request. Please try again.