mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-04 09:15:58 +02:00
feat: standarize titles
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user