feat: standarize titles

This commit is contained in:
Jean-Philippe Sirois
2019-09-17 02:40:12 -04:00
parent 3d0b733df4
commit edac103a42
4 changed files with 42 additions and 28 deletions
+27
View File
@@ -1,8 +1,35 @@
import chain from "ramda/es/chain"
import partition from "ramda/es/partition"
import pipe from "ramda/es/pipe"
import { IFile, IFileOrFolder, IFolder } from "../types"
function specificWordsToUpper(str: string): string {
const wordsToUpper = ["pdo", "c"]
const toUpper = (word: string) =>
wordsToUpper.includes(word.toLowerCase()) ? word.toUpperCase() : word
return str
.split(" ")
.map(toUpper)
.join(" ")
}
function removeDotMD(str: string): string {
return str.replace(".md", "")
}
function dashToSpace(str: string): string {
return str.replace(/-/g, " ")
}
export function humanize(str: string): string {
return pipe(
dashToSpace,
specificWordsToUpper,
removeDotMD
)(str)
}
export function traversePaths(
[head, ...tail]: string[],
basePath: string = "/resources"