Skip to content

Commit

Permalink
Update formats.js
Browse files Browse the repository at this point in the history
  • Loading branch information
tech4him1 authored Dec 1, 2017
1 parent 2ecc535 commit 9301ca5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/formats/formats.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import jsonFormatter from './json';
import FrontmatterFormatter from './frontmatter';

export const supportedFormats = [
'markdown',
'yml',
'yaml',
'toml',
'json',
'html',
'frontmatter',
];

export const formatToExtension = format => ({
markdown: 'md',
yml: 'yml',
yaml: 'yml',
toml: 'toml',
json: 'json',
html: 'html',
frontmatter: 'md',
}[format]);

export function formatByExtension(extension) {
Expand All @@ -37,9 +37,6 @@ function formatByName(name) {
yaml: yamlFormatter,
toml: tomlFormatter,
json: jsonFormatter,
md: FrontmatterFormatter,
markdown: FrontmatterFormatter,
html: FrontmatterFormatter,
frontmatter: FrontmatterFormatter,
}[name];
}
Expand All @@ -57,4 +54,7 @@ export function resolveFormat(collectionOrEntity, entry) {
const fileExtension = filePath.split('.').pop();
return formatByExtension(fileExtension);
}

// If no format is specified and it cannot be inferred, return the default.
return formatByName('frontmatter');
}

0 comments on commit 9301ca5

Please sign in to comment.