Skip to content

Commit ee871a1

Browse files
committed
fix: Change all config keys to use camelCase instead of snake case.
BREKAING CHANGE: All keys in your reptar.config.js have been updated to use camelCase. The keys that must be changed are: url_key -> urlKey date_format -> dateFormat future_date -> futureDate page_size -> pageSize clean_destination -> cleanDestination new_file_permalink -> newFilePermalink.
1 parent 933e004 commit ee871a1

15 files changed

Lines changed: 44 additions & 44 deletions

File tree

lib/cli/new.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default function (args) {
4949
data.date = moment().format('YYYY-M-D');
5050

5151
const filePath = Url.interpolatePermalink(
52-
config.get('new_file_permalink'),
52+
config.get('newFilePermalink'),
5353
data
5454
).toLowerCase();
5555
const fileContent = newType.template(data);

lib/collection/base.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,16 @@ export default class CollectionBase {
7676
this.template = collectionConfig.template;
7777
}
7878

79-
if (!_.isUndefined(collectionConfig.page_size)) {
80-
if (!_.isNumber(collectionConfig.page_size)) {
79+
if (!_.isUndefined(collectionConfig.pageSize)) {
80+
if (!_.isNumber(collectionConfig.pageSize)) {
8181
throw new Error('Page size must be a number');
8282
}
8383

8484
/**
8585
* Size of each CollectionPage.
8686
* @type {number}
8787
*/
88-
this.pageSize = collectionConfig.page_size;
88+
this.pageSize = collectionConfig.pageSize;
8989
}
9090

9191
if (!_.isUndefined(collectionConfig.sort)) {

lib/collection/type/file-system.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export default class FileSystemCollection extends CollectionBase {
124124
const files = CollectionBase.sortFiles(
125125
_.values(this.files),
126126
this.sort,
127-
this._config.get('file.date_format')
127+
this._config.get('file.dateFormat')
128128
);
129129

130130
// Break up our array of files into arrays that match our defined

lib/collection/type/metadata.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export default class MetadataCollection extends CollectionBase {
109109
const files = CollectionBase.sortFiles(
110110
rawFiles,
111111
this.sort,
112-
this._config.get('file.date_format')
112+
this._config.get('file.dateFormat')
113113
);
114114

115115
// Break up our array of files into arrays that match our defined

lib/config/config-example.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ module.exports = {
2727
file: {
2828
// What key from a File's frontmatter Reptar should use
2929
// as the property to grab the URL of the file from.
30-
url_key: 'url',
30+
urlKey: 'url',
3131
// The format that your date values are formatted as.
3232
// This is used when parsing date objects.
3333
// This current format supports dates like 2016-2-28
3434
// It uses moment.js under the head and its format syntax as well:
3535
// http://momentjs.com/docs////displaying/format/
36-
date_format: 'YYYY-M-D',
36+
dateFormat: 'YYYY-M-D',
3737
// Apply frontmatter values to a File based upon a defined scope.
3838
// If the scope matches a File then the default values are applied if they
3939
// are not already set.
@@ -62,7 +62,7 @@ module.exports = {
6262
// If any of the metadata values match then the File is filtered out.
6363
metadata: { draft: true },
6464
// If the date is in the future then it is filtered out.
65-
future_date: {
65+
futureDate: {
6666
// Customize what key we should use to pull the date value from.
6767
key: 'date',
6868
},
@@ -74,14 +74,14 @@ module.exports = {
7474
post: {
7575
path: './_posts',
7676
template: 'index',
77-
page_size: 6,
77+
pageSize: 6,
7878
sort: { key: 'date', order: 'descending' },
7979
permalink: { index: '/', page: '/page/:page/' },
8080
},
8181
tag: {
8282
metadata: 'tags',
8383
template: 'tag',
84-
page_size: 6,
84+
pageSize: 6,
8585
sort: { key: 'date', order: 'descending' },
8686
permalink: { index: '/tag/:metadata/', page: '/tag/:metadata/:page/' },
8787
},
@@ -111,7 +111,7 @@ module.exports = {
111111
},
112112
],
113113
// If we should remove the compile destination folder before writing.
114-
clean_destination: false,
114+
cleanDestination: false,
115115
// Slug options.
116116
// Options passed to node-slug
117117
slug: { lower: true },
@@ -136,7 +136,7 @@ module.exports = {
136136
// This is a performance improvement to the time it takes to build your site.
137137
incremental: true,
138138
// Where files created via `reptar new` should be placed.
139-
new_file_permalink: '/_posts/:date|YYYY-:date|MM-:date|D-:title.md',
139+
newFilePermalink: '/_posts/:date|YYYY-:date|MM-:date|D-:title.md',
140140
// What middlewares you want enabled and what configuration settings they
141141
// should have. Can be either a string which assumes it's an npm module or
142142
// a function which is the middleware itself, or an array of either.

lib/config/config-schema.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export default Joi.object({
2121
.default('./_data'),
2222
}).default(),
2323
file: Joi.object({
24-
url_key: Joi.string().default('url'),
25-
date_format: Joi.string().default('YYYY-M-D'),
24+
urlKey: Joi.string().default('url'),
25+
dateFormat: Joi.string().default('YYYY-M-D'),
2626
defaults: Joi.array().items(
2727
Joi.object({
2828
scope: Joi.object({
@@ -34,7 +34,7 @@ export default Joi.object({
3434
).default([]),
3535
filters: Joi.object({
3636
metadata: Joi.object(),
37-
future_date: Joi.object({
37+
futureDate: Joi.object({
3838
key: Joi.string().default('date'),
3939
}),
4040
}).default({}),
@@ -43,7 +43,7 @@ export default Joi.object({
4343
path: Joi.string(),
4444
metadata: Joi.string(),
4545
template: Joi.string().default('index'),
46-
page_size: Joi.number().default(6),
46+
pageSize: Joi.number().default(6),
4747
sort: Joi.object({
4848
key: Joi.string().default('date'),
4949
order: Joi.string().default('descending'),
@@ -73,7 +73,7 @@ export default Joi.object({
7373
{ test: /\.js$/, use: 'browserify' },
7474
{ test: /\.s[ac]ss$/, use: 'sass' },
7575
]),
76-
clean_destination: Joi.boolean().default(false),
76+
cleanDestination: Joi.boolean().default(false),
7777
slug: Joi.object({
7878
lower: Joi.boolean().default(true),
7979
}).default(),
@@ -101,7 +101,7 @@ export default Joi.object({
101101
baseurl: Joi.string().allow('').default(''),
102102
}).default(),
103103
incremental: Joi.boolean().default(true),
104-
new_file_permalink: Joi.string()
104+
newFilePermalink: Joi.string()
105105
.default('/_posts/:date|YYYY-:date|MM-:date|D-:title.md'),
106106
middlewares: middlewareOrLifecycleSchema,
107107
lifecycle: Joi.object({

lib/file.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,13 @@ export default class File {
204204

205205
/**
206206
* If the file itself wants to customize what its URL is then it will use
207-
* the `config.file.url_key` value of the File's frontmatter as the basis
207+
* the `config.file.urlKey` value of the File's frontmatter as the basis
208208
* for which the URL of this file should be.
209209
* So if you have a File with a frontmatter that has `url: /pandas/` then
210210
* the File's URL will be `/pandas/`.
211211
* @type {string?} url Relative path to file.
212212
*/
213-
const url = this.frontmatter[this._config.get('file.url_key')];
213+
const url = this.frontmatter[this._config.get('file.urlKey')];
214214

215215
if (url) {
216216
// If the individual File defined its own unique URL that gets first

lib/filter/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import _ from 'lodash';
22
import metadata from './metadata';
3-
import future_date from './future-date';
3+
import futureDate from './future-date';
44

55
const filters = {
66
metadata,
7-
future_date,
7+
futureDate,
88
};
99

1010
export default {

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export default class Reptar {
201201
reptar: this,
202202
});
203203

204-
if (this.config.get('clean_destination') || this.options.clean) {
204+
if (this.config.get('cleanDestination') || this.options.clean) {
205205
await this.cleanDestination();
206206
}
207207

lib/renderer/template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function addBuiltinFilters(env, config) {
9191
return '';
9292
}
9393

94-
return moment(date, config.get('file.date_format'))
94+
return moment(date, config.get('file.dateFormat'))
9595
.format(momentTemplate);
9696
}
9797

0 commit comments

Comments
 (0)