Skip to content

Commit

Permalink
Merge pull request #269 from benbalter/frontmatter-all-the-things
Browse files Browse the repository at this point in the history
Detect YAML frontmatter on any file, regardless of type
  • Loading branch information
dhcole committed Mar 25, 2013
2 parents 54817eb + cac8038 commit b2ea449
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions _includes/model.js
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions _includes/util.js
Expand Up @@ -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
// -------
Expand Down

0 comments on commit b2ea449

Please sign in to comment.