-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththeme.config.tsx
153 lines (142 loc) · 3.6 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
import { useRouter } from "next/router";
import { useConfig, useTheme, DocsThemeConfig } from "nextra-theme-docs";
import { Footer } from "./src/components/ui/footer";
import { OttoFMSLogo } from "@/components/logos/ottofms";
import { IconExternalLink } from "@tabler/icons-react";
import "./src/styles/globals.css";
import NoSsr from "@/components/no-ssr";
import { TopRightLogo } from "@/components/ui/top-right-logo";
const config: DocsThemeConfig = {
primaryHue: 201,
logo: Logo,
darkMode: true,
head: Head,
sidebar: {
defaultMenuCollapseLevel: 1,
titleComponent: ({ title, type }) => {
if (title === "Coming from Otto v3") {
return (
<span
style={{ fontSize: "16px", fontWeight: "900", color: "#0977B1" }}
>
{title}
</span>
);
}
return <>{title}</>;
},
},
docsRepositoryBase: "https://pr.new/proofgeist/ottofms-docs/edit/main",
footer: { component: Footer },
feedback: { content: null },
editLink: {
component: withoutServerEditLink,
},
useNextSeoProps() {
return {
titleTemplate: `%s | OttoFMS`,
};
},
navbar: {
extraContent: <TopRightLogo />,
},
};
export default config;
function getBaseUrl() {
const productionUrl = "https://docs.ottofms.com";
const localDevUrl = "http://localhost:3063";
const devOrPreview = process.env.NEXT_PUBLIC_VERCEL_URL
? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`
: localDevUrl;
const vercelENV = process.env.NEXT_PUBLIC_VERCEL_ENV;
const url = vercelENV === "production" ? productionUrl : devOrPreview;
return url;
}
function Head() {
const baseUrl = getBaseUrl();
const { asPath, defaultLocale, locale } = useRouter();
const { frontMatter, title } = useConfig();
const url =
baseUrl + (defaultLocale === locale ? asPath : `/${locale}${asPath}`);
return (
<>
<meta property="og:url" content={url} />
<meta
property="og:description"
content={frontMatter.description || "OttoFMS Documentation"}
/>
<meta
property="og:image"
content={`${baseUrl}/api/og-image?title=${title}&subTitle=${
frontMatter.subTitle || ""
}`}
/>
<meta
property="twitter:title"
content={title || "OttoFMS Documentation"}
/>
<meta
property="twitter:image"
content={`${baseUrl}/api/og-image?title=${title}&subTitle=${
frontMatter.subTitle || ""
}`}
/>
<meta
property="twitter:description"
content={frontMatter.description || "OttoFMS Documentation"}
/>
</>
);
}
function Logo() {
const { theme } = useTheme();
return (
<div
style={{
display: "flex",
gap: "32px",
flexDirection: "row",
justifyContent: "space-between",
}}
>
<OttoFMSLogo scale={0.55} />
</div>
);
}
function EditLink({
filePath,
className,
}: {
filePath?: string | undefined;
className?: string | undefined;
}) {
return (
<a
className={className}
target="_blank"
href={`https://pr.new/proofgeist/ottofms-docs/edit/main/${filePath}?initialPath=${window.location.pathname.replace(
"/",
""
)}`}
style={{ display: "flex", gap: 6, alignItems: "center" }}
>
Edit This page <IconExternalLink size={18} />
</a>
);
}
function withoutServerEditLink({
filePath,
className,
}: {
filePath?: string | undefined;
className?: string | undefined;
}) {
return (
<NoSsr>
<EditLink filePath={filePath} className={className} />
</NoSsr>
);
}
function Null() {
return <></>;
}