mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-04 09:05:49 -05:00
Co-authored-by: Muhammed Mustafa <muhammed@freecodecamp.org> Co-authored-by: ahmad abdolsaheb <ahmad.abdolsaheb@gmail.com> Co-authored-by: Muhammed Mustafa <MuhammedElruby@gmail.com>
35 lines
1.0 KiB
JavaScript
35 lines
1.0 KiB
JavaScript
'use strict';
|
|
var __importDefault =
|
|
(this && this.__importDefault) ||
|
|
function (mod) {
|
|
return mod && mod.__esModule ? mod : { default: mod };
|
|
};
|
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
exports.blockNameify = void 0;
|
|
const preformatted_block_names_json_1 = __importDefault(
|
|
require('./preformatted-block-names.json')
|
|
);
|
|
const preformatted_words_json_1 = __importDefault(
|
|
require('./preformatted-words.json')
|
|
);
|
|
const noFormatting = ['and', 'for', 'of', 'the', 'up', 'with', 'to', 'by', 'a'];
|
|
function blockNameify(phrase) {
|
|
const preFormatted = preformatted_block_names_json_1.default[phrase] || '';
|
|
if (preFormatted) {
|
|
return preFormatted;
|
|
}
|
|
return phrase
|
|
.split('-')
|
|
.map(word => {
|
|
if (noFormatting.indexOf(word) !== -1) {
|
|
return word;
|
|
}
|
|
if (preformatted_words_json_1.default[word]) {
|
|
return preformatted_words_json_1.default[word];
|
|
}
|
|
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
})
|
|
.join(' ');
|
|
}
|
|
exports.blockNameify = blockNameify;
|