-
Notifications
You must be signed in to change notification settings - Fork 0
/
theme.config.tsx
117 lines (110 loc) · 3.52 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
import Link from "next/link";
import { useRouter } from "next/router";
import { useConfig } from "nextra-theme-docs";
import { ReactNode, useEffect, useState } from "react";
import { Footer } from "./components/Footer";
import { Icons } from "./components/icons";
const themeConfig = {
logo: <span className="tracking-widest font-semibold">Aidos Kanapyanov</span>,
search: {
placeholder: "Search in blog…",
},
project: {
link: "https://github.com/aidoskanapyanov",
icon: <Icons.github dim={false} />,
},
chat: {
link: "https://www.linkedin.com/in/aidos-kanapyanov/",
icon: <Icons.linkedin dim={false} />,
},
useNextSeoProps() {
const { asPath } = useRouter();
if (asPath === "/") {
return {
titleTemplate: "Aidos Kanapyanov",
};
}
return {
titleTemplate: "%s | Aidos Kanapyanov",
};
},
gitTimestamp({ timestamp }: { timestamp: Date }) {
// eslint-disable-next-line react-hooks/rules-of-hooks
const [dateString, setDateString] = useState(timestamp.toISOString());
// eslint-disable-next-line react-hooks/rules-of-hooks
useEffect(() => {
try {
setDateString(
timestamp.toLocaleDateString(navigator.language, {
day: "numeric",
month: "long",
year: "numeric",
})
);
} catch (e) {
// Ignore errors here; they get the ISO string.
// At least one person out there has manually misconfigured navigator.language.
}
}, [timestamp]);
return <>Last updated on {dateString}</>;
},
footer: {
component: Footer,
},
feedback: {
content: null,
},
editLink: {
text: null,
},
components: {
a: ({ href, children }: { href: string; children: ReactNode }) => (
<Link
href={href}
className="font-semibold decoration-dotted decoration-2 underline underline-offset-4 hover:no-underline"
>
{children}
</Link>
),
h1: ({ children }: { children: ReactNode }) => (
<h1 className="text-center leading-snug text-5xl mt-4 mb-16 nx-text-slate-900 dark:nx-text-slate-100">
{children}
</h1>
),
p: ({ children }: { children: ReactNode }) => (
<p className="nx-mt-8 nx-leading-7 first:nx-mt-0">{children}</p>
),
ul: ({ children }: { children: ReactNode }) => (
<ul className="nx-mt-8 nx-list-disc first:nx-mt-0 ltr:nx-ml-6 rtl:nx-mr-6">
{children}
</ul>
),
},
head: function Head() {
const router = useRouter();
const { frontMatter } = useConfig();
const origin =
typeof window !== "undefined" && window.location.origin
? window.location.origin
: "";
const fullUrl =
router.asPath === "/" ? origin : `${origin}${router.asPath}`;
const ogUrl = `${origin}${frontMatter.ogImage}`;
const author = frontMatter.author || "Aidos Kanapyanov";
return (
<>
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content={frontMatter.title} />
<meta name="twitter:description" content={frontMatter.description} />
<meta name="twitter:image" content={ogUrl} />
<meta property="og:type" content="website" />
<meta property="og:url" content={fullUrl} />
<meta name="image" property="og:image" content={ogUrl} />
<meta name="author" content={author}></meta>
<meta property="og:site_name" content="Aidos Kanapyanov" />
<link rel="canonical" href={fullUrl} />
</>
);
},
};
export default themeConfig;