Repository navigation
Expand file tree
/
Copy pathroot.tsx
More file actions
65 lines (57 loc) · 1.53 KB
/
Copy pathroot.tsx
File metadata and controls
65 lines (57 loc) · 1.53 KB
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
import { Fragment } from "react"
import { Head } from "minista"
import type { MinistaLocation } from "minista"
import "highlight.js/styles/nord.css"
import "@fontsource/montserrat/800.css"
import "./root.css"
import AppLayout from "./components/app-layout"
export const getStaticData = async () => {
const apiUrl = "https://api.github.com/repos/qrac/minista"
const response = await fetch(apiUrl)
const data = await response.json()
return {
props: {
global: {
title: data.name,
description: data.description,
},
components: {
h2: (props) => <h2 className="mdx-components-test" {...props} />,
},
},
}
}
export type GlobalProps = {
title: string
description: string
}
export type FrontmatterProps = {
title?: string
layout?: string
draft?: boolean
}
type RootProps = {
global: GlobalProps
frontmatter?: FrontmatterProps
location: MinistaLocation
children: React.ReactNode
}
const Root = ({ global, frontmatter, location, children }: RootProps) => {
const ogType = location.pathname === "/" ? "website" : "article"
const Layout = frontmatter?.layout === "AppLayout" ? AppLayout : Fragment
return (
<>
<Head>
<title>
{frontmatter?.title
? frontmatter?.title + " | " + global?.title
: global?.title}
</title>
<meta name="description" content={global?.description}></meta>
<meta property="og:type" content={ogType} />
</Head>
<Layout>{children}</Layout>
</>
)
}
export default Root