forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocs.js
More file actions
98 lines (87 loc) · 2.09 KB
/
docs.js
File metadata and controls
98 lines (87 loc) · 2.09 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import { graphql } from 'gatsby';
import React from 'react';
import EditIcon from 'react-icons/lib/go/pencil';
import Layout from '../components/layout';
import DocSearch from '../components/DocSearch';
import PageContainer from '../components/PageContainer';
import StickyNavigation from '../components/StickyNavigation';
import TitleAndMetaTags from '../components/TitleAndMetaTags';
import {
Article,
Container,
Description,
DocsContainer,
DocsNavigation,
DocumentationContent,
Edit,
Heading,
Title,
} from './_docs.elements';
const Docs = ({
data: {
allDocs: { edges: docs },
doc: {
fields: { description, editLink, title },
html,
},
},
}) => (
<Layout>
<Container>
<TitleAndMetaTags
description={description}
title={`${title} - CodeSandbox Documentation`}
/>
<PageContainer>
<DocsContainer>
<DocsNavigation>
<DocSearch />
<StickyNavigation docs={docs} />
</DocsNavigation>
<Article>
<Heading>
<Title>{title}</Title>
<Edit href={editLink} rel="noreferrer noopener" target="_blank">
<EditIcon /> Edit this page
</Edit>
<Description>{description}</Description>
</Heading>
<DocumentationContent dangerouslySetInnerHTML={{ __html: html }} />
</Article>
</DocsContainer>
</PageContainer>
</Container>
</Layout>
);
export default Docs;
export const pageQuery = graphql`
query Docs($slug: String!) {
allDocs: allMarkdownRemark(
filter: { fileAbsolutePath: { regex: "/docs/" } }
sort: { fields: [fileAbsolutePath], order: [ASC] }
) {
edges {
node {
fields {
slug
title
}
headings(depth: h2) {
value
}
}
}
}
doc: markdownRemark(
fileAbsolutePath: { regex: "/docs/" }
fields: { slug: { eq: $slug } }
) {
fields {
description
editLink
title
}
html
}
}
`;