-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.ts
47 lines (39 loc) · 1003 Bytes
/
utils.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { sideBarLink } from "./src/components/sideBar"
//Get rid of hyphens for auto-generated page titles.
const sanitizeTitle = (rawString: string): string =>
rawString.split("-").join(" ")
const allocateArray = (orig: Array<any>, numKids: number) => {}
const copy = (orig: any) => JSON.parse(JSON.stringify(orig))
const isNotNavDupe = (target: sideBarLink, array: Array<sideBarLink>) => {
const titleArray = array.map(link => link.title)
return !titleArray.includes(target.title)
}
const convertToSlug = (string: String) => {
return string.split(" ").join("-").toLowerCase()
}
const months = [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
]
const convertStringToDate = (string: string): string => {
const date = new Date(string)
return `${months[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`
}
export {
sanitizeTitle,
allocateArray,
copy,
isNotNavDupe,
convertToSlug,
convertStringToDate,
}