-
Notifications
You must be signed in to change notification settings - Fork 0
/
theme.config.tsx
126 lines (115 loc) · 4.28 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
import React, { useEffect, useState } from 'react';
import Image from 'next/image';
import { useConfig, DocsThemeConfig } from 'nextra-theme-docs';
import Link from 'next/link';
import SelectVersion from './components/select-version/SelectVersion';
import { FaXTwitter } from "react-icons/fa6";
const config: DocsThemeConfig = {
head: function useHead() {
const config = useConfig<{ description?: string; image?: string }>();
const description = config.frontMatter.description || 'Website description';
const title = `${config.title}| Wemical`;
return (
<>
<title>{title}</title>
<meta property="og:title" content={title} />
<meta name="description" content={description} />
<meta property="og:description" content={description} />
{/* Favicons, meta */}
{/* Get favicon here from png */}
{/* https://favicon.io/favicon-converter/#google_vignette */}
<link rel="apple-touch-icon" sizes="180x180" href="/logo/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/logo/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/logo/favicon-16x16.png" />
<link rel="manifest" href="/logo/site.webmanifest" />
</>
);
},
notFound: {
content: () => {
return (
<h1>Not found</h1>
)
},
labels: "Not found 404"
},
toc: {
backToTop: true,
float: true
},
logoLink: false,
logo: function useRouterLogo() {
const [selectedVersion, setSelectedVersion] = useState('v1.0.1');
const [renderSelect, setRenderSelect] = useState(true);
const versionsArr = [ 'v1.0.1']; // Danh sách các phiên bản có sẵn
useEffect(() => {
const pathArray = window.location.pathname.split('/');
setRenderSelect(pathArray.includes('docs') && pathArray[1] === 'docs');
const currentVersion = pathArray[pathArray.length - 1];
if (currentVersion === 'latest') {
const latestVersion = versionsArr.sort((a, b) => (a > b ? -1 : 1))[0];
setSelectedVersion(latestVersion);
} else if (versionsArr.includes(currentVersion)) {
setSelectedVersion(currentVersion);
}
}, [versionsArr]);
const handleChange = (e) => {
let version = e.target.value;
const latestVersion = versionsArr.sort((a, b) => (a > b ? -1 : 1))[0];
if (version === latestVersion) {
version = 'latest';
}
setSelectedVersion(version);
if (version) {
window.location.href = `/docs/${version}`;
}
};
return (
<div className='flex flex-row'>
<Link
href="/"
className="hidden sm:flex items-center text-current no-underline hover:opacity-75 ltr:mr-auto rtl:ml-auto"
>
<span className='font-sans font-[700] text-[24px] text-[#00ff7f] border-b-[2px] border-[#000]'>NEAR</ span>
<span className='font-sans font-[700] text-[24px] text-[#000] border-b-[2px] border-[#00ff7f]'>STACK</ span>
{/* <Image src="/logo/logo1.png" alt="logo" width={100} height={45} /> */}
{/* <span className="select-none font-bold ltr:ml-2 rtl:mr-2 inline">Wemical</span> */}
</Link>
{
renderSelect &&
<select
value={selectedVersion}
onChange={handleChange}
className="bg-gray-100 sm:ms-[80px] py-2 px-4 pe-3 block w-full border-gray-200 rounded-lg text-sm focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-900 dark:border-neutral-700 dark:text-neutral-400 dark:placeholder-neutral-500 dark:focus:ring-neutral-600"
>
{versionsArr.map((version) => (
<option key={version} value={version}>
{version}
</option>
))}
</select>
}
</div>
);
},
darkMode: false,
sidebar: {
toggleButton: true,
defaultMenuCollapseLevel: 1
},
project: {
link: 'https://github.com/Weminal-labs/nearstack',
},
chat: {
icon:<FaXTwitter />,
link: 'https://x.com/Nearstacks',
},
docsRepositoryBase: 'https://github.com/shuding/nextra-docs-template',
footer: {
component: (
<footer className="bg-transparent">
</footer>
),
},
}
export default config