-
Notifications
You must be signed in to change notification settings - Fork 0
/
theme.config.tsx
194 lines (180 loc) · 5.25 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
/**
* @type {import('nextra-theme-docs').DocsThemeConfig}
*/
import { useRouter } from 'next/router';
const github = 'https://github.com/ismoilovdevml/os-dev-blog';
const TITLE_WITH_TRANSLATIONS = {
'UZ': 'UZ',
} as const;
const EDIT_LINK_WITH_TRANSLATIONS = {
'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 src="/hero.png" alt="Hero" height="50" width="50"/>
<span style={{ fontWeight: 'bold', fontSize: 18 }}>Otabek Ismoilov</span>
</div>
);
};
const config: DocsThemeConfig = {
docsRepositoryBase: `${github}/blob/main`,
chat: {
link: 'https://discord.gg/rq9rUdnKpm',
},
banner: {
key: 'docs-launch',
text: (
<div className="flex justify-center items-center gap-2">
Open Source Developer Blog
</div>
),
},
toc: {
float: true,
},
project: {
link: github,
},
darkMode: true,
nextThemes: {
defaultTheme: 'dark',
},
primaryHue: {
dark: 162,
light: 212,
},
footer: {
text: `CC0-1.0 Licensed | Hamma xuquqlar himoyalangan ${new Date().getFullYear()} ©Uzinfocom Open Source.`,
},
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 - OS-Dev-Blog`,
};
},
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 || 'Open Source Developer Blog';
const description =
frontMatter?.description ||
"Open Source Developer Blog";
const image = frontMatter?.type
? `https://os-dev-blog.uz/api/og?title=${frontMatter?.ogImageText}&category=Developing`
: frontMatter?.image || '/og.jpg';
const folder = theme === 'light' ? '/light' : '/dark';
const composedTitle = `${title} – OS-Dev-Blog`;
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:site" content="@livepeer" />
<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="Otabek Ismoilov"
/>
<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) ?? 'UZ'
]
}
</>
);
},
},
i18n: [{ locale: 'UZ', text: 'O\'zbekcha' }],
gitTimestamp: ({ timestamp }) => (
<>Last updated on {timestamp.toLocaleDateString()}</>
),
};
export default config;