-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.ts
147 lines (135 loc) · 3.35 KB
/
config.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
const siteMetadata = {
title: `Domratchev.dev`,
siteUrl: `http://localhost`,
capitalizeTitleOnHome: false,
logo: `/images/logo.png`,
icon: `/images/icon.png`,
titleImage: `/images/wall.jpg`,
ogImage: '',
twoColumnWall: false,
cookiePolicy: true,
introTag: `Developer by Day, Hacker by Night`,
description: '',
about: {
image: `/images/image.png`,
content: "Hello! I am a full stack developer with over 10 years of experience. I am currently diving into Elixir in hopes to write less Javascript. 🤷♂️ Sorry",
},
author: `@antonromatchev`,
blogItemsPerPage: 10,
portfolioItemsPerPage: 10,
darkmode: true,
switchTheme: false,
navLinks: [
{
name: "HOME",
url: "/",
},
{
name: "ABOUT",
url: "/about",
},
{
name: "BLOG",
url: "/blog",
},
],
footerLinks: [
{
name: "PRIVACY POLICY",
url: "/privacy-policy",
},
{
name: "GitHub",
url: "https://github.com/antondomratchev",
},
],
social: [
{
name: "Twitter",
icon: "/images/Twitter.svg",
url: "#",
},
],
contact: {
// leave empty ('') or false to hide form
api_url: "",
description: `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sit amet accumsan arcu. Proin ac consequat arcu.`,
mail: "[email protected]",
phone: "000-000-0000",
address: "1234 \nLocation \nLocation",
},
disqus: "",
}
const beforeContactFormSubmit = data => {
// Code 0 - success
// Code 1 - Name
// Code 2 - Email
// Code 3 - Message
// Code 4 - Other
const errors = []
if (data.name.trim().length < 2) {
errors.push({
code: 1,
message: "Enter a name",
})
}
if (!data.email.match(/[^@ \t\r\n]+@[^@ \t\r\n]+\.[^@ \t\r\n]+/)) {
errors.push({
code: 2,
message: "Enter a valid email address",
})
}
if (data.message.trim().length < 15) {
errors.push({
code: 3,
message: "Enter a message with atleast 15 characters",
})
}
if (errors.length > 0)
return {
result: false,
errors: errors,
}
return {
data: {
name: data.name,
email: data.email,
message: data.message,
},
result: true,
}
}
const contactFormSubmit = async (api, data) => {
let res: any = await fetch(api, {
method: "POST",
body: JSON.stringify(data),
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
})
res = await res.json()
if (res.success) {
return {
result: true,
}
}
return {
result: false,
...res,
}
}
const defaults = {
disqus: null,
twoColumnWall: true,
darkmode: false,
switchTheme: true,
capitalizeTitleOnHome: true,
cookiePolicy: false
}
Object.keys(defaults).forEach(item => {
if (siteMetadata[item] === undefined) {
siteMetadata[item] = defaults[item]
}
})
export { siteMetadata, beforeContactFormSubmit, contactFormSubmit }