-
Notifications
You must be signed in to change notification settings - Fork 4
/
theme.config.tsx
101 lines (91 loc) · 3.53 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
import React, { useEffect, useState } from 'react'
import { DocsThemeConfig, useConfig } from 'nextra-theme-docs'
import { useRouter } from 'next/router'
import { getCopyrightText } from '@/util/String'
import { selectTranslations } from '@/features/i18n/TranslatorSlice'
import { useSelector } from 'react-redux'
const config: DocsThemeConfig = {
docsRepositoryBase: 'https://github.com/MohistMC/website/tree/frontend',
footer: {
component: function () {
return <></>
},
},
useNextSeoProps: function SEO() {
const router = useRouter()
const { frontMatter } = useConfig()
const section = router?.pathname.startsWith('/mohist')
? 'Mohist'
: router?.pathname.startsWith('/blog')
? 'Blog'
: 'Banner'
const defaultTitle = frontMatter.overrideTitle || section
return {
defaultTitle,
titleTemplate: `%s – ${section}`,
}
},
head: function useHead() {
const router = useRouter()
const section = router?.pathname.startsWith('/mohist')
? 'Mohist'
: router?.pathname.startsWith('/blog')
? 'Blog'
: 'Banner'
const description =
section === 'Blog'
? `Stay updated with MohistMC's Blog! Explore the latest news, releases, and insights. Connect with our dynamic community. ${getCopyrightText()} MohistMC.`
: `Need help setting up, configuring and using our software? The docs are here to help you. ${getCopyrightText()} MohistMC.`
const title = section === 'Blog' ? 'MohistMC - Blog' : 'MohistMC - Docs'
return (
<>
<meta name="title" content={title} />
<meta name="description" content={description} />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://mohistmc.com/team" />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta
property="og:image"
content="https://mohistmc.com/mohistLogo.png"
/>
<meta property="og:image:type" content="image/png" />
<meta property="og:image:width" content="100" />
<meta property="og:image:height" content="100" />
<meta
property="twitter:url"
content="https://mohistmc.com/team"
/>
<meta property="twitter:title" content={title} />
<meta property="twitter:description" content={description} />
</>
)
},
themeSwitch: {
component: null,
},
editLink: {
text: 'Edit this page on GitHub',
},
gitTimestamp: function GitTimestamp({ timestamp }) {
const [dateString, setDateString] = useState(timestamp.toISOString())
const strings = useSelector(selectTranslations)
useEffect(() => {
try {
setDateString(
timestamp.toLocaleDateString(navigator.language, {
day: 'numeric',
month: 'long',
year: 'numeric',
}),
)
} catch (e) {}
}, [timestamp])
return (
<>
{strings['blog.lastupdated']} {dateString}
</>
)
},
}
export default config