-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
theme.config.tsx
206 lines (191 loc) · 5.76 KB
/
theme.config.tsx
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
/**
* @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',
} as const;
const EDIT_LINK_WITH_TRANSLATIONS = {
'en-UZ': "GitHub-da o'zgartirish ->",
} 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: `GPL-3.0 Licensed | Hamma huquqlar himoyalangan ${new Date().getFullYear()} ©Uzbek Developers Consortium.`,
},
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();
const title = frontMatter?.title || 'DevOps Journey';
const description =
frontMatter?.description ||
"DevOps bo'yicha bepul ta'lim platformasi bo'lgan DevOps Journey-ga xush kelibsiz";
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="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' }],
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;