This repository was archived by the owner on Apr 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathlearn.tsx
More file actions
84 lines (80 loc) · 1.98 KB
/
learn.tsx
File metadata and controls
84 lines (80 loc) · 1.98 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import { graphql } from 'gatsby';
import React from 'react';
import Article from '../sections/Article';
import DefaultLayout from '../layouts/default';
import LearnNavigation from '../navigations/learn';
import { connectGraphQlCustom } from '../connectGraphQlArticle';
import { LearnTemplateContext, LearnTemplateData } from '../types';
interface Props {
data: LearnTemplateData;
pageContext: LearnTemplateContext;
location: Location;
}
const LearnLayout = ({
data: {
article: {
frontmatter: { displayTitle, description },
body,
tableOfContents,
fields: { authors },
},
},
pageContext: { slug, next, previous, relativePath, navigationData },
}: Props): JSX.Element => (
<DefaultLayout title={displayTitle} description={description}>
<main className="grid-container">
<LearnNavigation sections={navigationData} currentSlug={slug} />
<Article
title={displayTitle}
description={description}
body={body}
tableOfContents={tableOfContents ? tableOfContents.items : []}
next={next}
authors={authors}
previous={previous}
relativePath={relativePath}
/>
</main>
</DefaultLayout>
);
export default connectGraphQlCustom(LearnLayout);
export const query = graphql`
query ($slug: String!, $locale: String!, $defaultLocale: String!) {
articleCurrentLanguage: mdx(
fields: {
slug: { eq: $slug }
categoryName: { eq: "learn" }
locale: { eq: $locale }
}
) {
body
tableOfContents
frontmatter {
displayTitle
description
}
fields {
slug
authors
}
}
articleDefaultLanguage: mdx(
fields: {
slug: { eq: $slug }
categoryName: { eq: "learn" }
locale: { eq: $defaultLocale }
}
) {
body
tableOfContents
frontmatter {
displayTitle
description
}
fields {
slug
authors
}
}
}
`;