-
-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy paththeme.config.tsx
More file actions
231 lines (215 loc) · 6.97 KB
/
theme.config.tsx
File metadata and controls
231 lines (215 loc) · 6.97 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/**
* @type {import('nextra-theme-docs').DocsThemeConfig}
*/
import { useRouter } from 'next/router';
import { GithubSponsors } from '@components/github-sponsors';
import dynamic from 'next/dynamic';
const Zoom = dynamic(() => import('react-medium-image-zoom'), {
ssr: false,
})
const github = 'https://github.com/ismoilovdevml/devops-journey';
const TITLE_WITH_TRANSLATIONS = {
'en-UZ': 'DevOps Journey',
'en': 'DevOps Journey',
'ru': 'DevOps Journey',
} as const;
const EDIT_LINK_WITH_TRANSLATIONS = {
'en-UZ': "GitHub-da o'zgartirish ->",
'en': 'Edit this page on GitHub ->',
'ru': 'Редактировать на GitHub ->',
} as const;
import { DocsThemeConfig, useConfig, useTheme } from 'nextra-theme-docs';
const Logo = ({ height, width }: { height: number; width: number }) => {
const { theme } = useTheme();
return (
<div style={{ alignItems: 'center', display: 'flex', gap: '8px' }}>
<svg
width={height || 18}
height={width || 18}
viewBox="0 0 64 68"
fill="none"
>
<use href="public/logos/logo-dark.svg" />
</svg>
<img className='logo-img' src="/hero.png" alt="Hero" height="50" width="50" />
<span className='logo-text' style={{ fontWeight: 'bold', fontSize: 18 }}>DevOps Journey</span>
</div>
);
};
const ArticleFooter = dynamic(() => import("@components/article-footer"), { ssr: false })
const config: DocsThemeConfig = {
docsRepositoryBase: `${github}/blob/main`,
chat: {
link: 'https://discord.gg/rq9rUdnKpm',
},
toc: {
float: true,
},
project: {
link: github,
},
darkMode: true,
nextThemes: {
defaultTheme: 'dark',
},
primaryHue: {
dark: 162,
light: 212,
},
footer: {
text() {
// eslint-disable-next-line react-hooks/rules-of-hooks
const { locale } = useRouter();
const footerTexts: Record<string, string> = {
'en-UZ': `GPL-3.0 Licensed | Hamma huquqlar himoyalangan ${new Date().getFullYear()} ©Uzbek Developers Consortium.`,
'en': `GPL-3.0 Licensed | All rights reserved ${new Date().getFullYear()} ©Uzbek Developers Consortium.`,
'ru': `GPL-3.0 Лицензия | Все права защищены ${new Date().getFullYear()} ©Uzbek Developers Consortium.`,
};
return <>{footerTexts[locale as string] || footerTexts['en-UZ']}</>;
},
},
navbar: {
extraContent: <GithubSponsors />,
},
logo() {
// eslint-disable-next-line react-hooks/rules-of-hooks
return (
<div className="flex items-center gap-2">
<Logo width={18} height={18} />
</div>
);
},
useNextSeoProps() {
return {
titleTemplate: `%s - DevOps Journey`,
};
},
head() {
// eslint-disable-next-line react-hooks/rules-of-hooks
const { frontMatter } = useConfig();
// eslint-disable-next-line react-hooks/rules-of-hooks
const { theme } = useTheme();
// eslint-disable-next-line react-hooks/rules-of-hooks
const { locale } = useRouter();
const title = frontMatter?.title || 'DevOps Journey';
const defaultDescriptions: Record<string, string> = {
'en-UZ': "DevOps bo'yicha bepul ta'lim platformasi bo'lgan DevOps Journey-ga xush kelibsiz",
'en': "Welcome to DevOps Journey - a free educational platform for DevOps",
'ru': "Добро пожаловать в DevOps Journey - бесплатная образовательная платформа по DevOps",
};
const description =
frontMatter?.description ||
defaultDescriptions[locale as string] || defaultDescriptions['en-UZ'];
const image = frontMatter?.type
? `https://devops-journey.uz/api/og?title=${frontMatter?.ogImageText}&category=Developing`
: frontMatter?.image || '/banner.png';
const folder = theme === 'light' ? '/light' : '/dark';
const composedTitle = `${title} - DevOps Journey`;
return (
<>
<link
rel="apple-touch-icon"
sizes="180x180"
href={`${folder}/apple-touch-icon.png`}
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href={`${folder}/favicon-32x32.png`}
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href={`${folder}/favicon-16x16.png`}
/>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link
rel="preconnect"
href="https://fonts.gstatic.com"
crossOrigin="true"
/>
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap"
rel="stylesheet"
/>
<meta name="theme-color" content="#ffffff" />
<meta name="msapplication-TileColor" content="#00a300" />
<link rel="manifest" href={`${folder}/site.webmanifest`} />
<meta httpEquiv="Content-Language" content={locale || 'en'} />
<meta name="title" content={composedTitle} />
<meta name="description" content={description} />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content={image} />
<meta property="og:description" content={description} />
<meta property="og:title" content={composedTitle} />
<meta property="og:image" content={image} />
<meta property="og:type" content="website" />
<meta
name="apple-mobile-web-app-title"
content="DevOps Journey"
/>
<script
async
src="https://www.googletagmanager.com/gtag/js?id=G-YNF68V1ND1"
></script>
<script>
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-YNF68V1ND1');
`}
</script>
</>
);
},
sidebar: {
defaultMenuCollapseLevel: 1,
titleComponent: ({ title, type }) =>
type === 'separator' ? (
<div className="flex items-center gap-2">
<Logo height={10} width={10} />
{title}
</div>
) : (
<>{title}</>
),
},
editLink: {
text() {
// eslint-disable-next-line react-hooks/rules-of-hooks
const { locale } = useRouter();
return (
<>
{
EDIT_LINK_WITH_TRANSLATIONS[
(locale as keyof typeof EDIT_LINK_WITH_TRANSLATIONS) ?? 'en-UZ'
]
}
</>
);
},
},
i18n: [
{ locale: 'en-UZ', text: "O'zbek" },
{ locale: 'en', text: 'English' },
{ locale: 'ru', text: 'Русский' },
],
gitTimestamp: ({ timestamp }) => (
<>Last updated on {timestamp.toLocaleDateString()}</>
),
components: {
img: props => <Zoom><img {...props} /></Zoom>
},
main({ children }) {
// eslint-disable-next-line react-hooks/rules-of-hooks
const { frontMatter: { showFooter } } = useConfig();
return <>
{children}
{showFooter != false && <ArticleFooter />}
</>
}
};
export default config;