Skip to content

Commit 63073fa

Browse files
author
Alban Bailly
committed
querying
1 parent 7e46cc4 commit 63073fa

File tree

3 files changed

+77
-12
lines changed

3 files changed

+77
-12
lines changed

gatsby-node.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ exports.createPages = async ({ actions, graphql }) => {
113113
allPaths {
114114
edges {
115115
node {
116+
id
116117
name
117118
}
118119
}

src/components/2_molecules/sidemenu.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,23 @@ const SideMenu = ({ data }) => {
88
{nodes.map((node, i) => {
99
const n = node.node;
1010
return (
11-
<li key={i} className="list-reset">
12-
<a href={`/api/v4${n.name}`}>
13-
{(n.get && n.get.summary) ||
14-
(n.post && n.post.summary) ||
15-
(n.put && n.put.summary)}
16-
</a>
17-
</li>
11+
<div key={i}>
12+
{n.get && (
13+
<li className="list-reset">
14+
<a href={`/api/v4${n.name}`}>{n.get.summary}</a>
15+
</li>
16+
)}
17+
{n.post && (
18+
<li className="list-reset">
19+
<a href={`/api/v4${n.name}`}>{n.post.summary}</a>
20+
</li>
21+
)}
22+
{n.put && (
23+
<li className="list-reset">
24+
<a href={`/api/v4${n.name}`}>{n.put.summary}</a>
25+
</li>
26+
)}
27+
</div>
1828
);
1929
})}
2030
</ul>
@@ -28,9 +38,6 @@ export default props => (
2838
allPaths {
2939
edges {
3040
node {
31-
internal {
32-
contentDigest
33-
}
3441
name
3542
get {
3643
summary

src/components/5_templates/api.js

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,78 @@
11
import React from "react";
2+
import { graphql } from "gatsby";
23

34
import Layout from "../../components/4_layouts/layout";
45
import SEO from "../../components/0_utlilities/seo";
56
import Sidebar from "../../components/2_molecules/sidemenu";
67

7-
const apiPage = () => {
8+
const apiPage = ({ data }) => {
9+
// const node = pageContext.name;
10+
const n = data.allPaths.edges[0].node;
11+
console.log(n);
812
return (
913
<Layout title="API Documentation" subtitle="Linode API Documentation">
1014
<SEO title="API Documentation" description="" />
1115
<div className="flex flex-wrap">
1216
<div className="w-full md:w-1/4 mt-8">
1317
<Sidebar />
1418
</div>
15-
poos
19+
<div className="w-full md:w-3/4 pl-8">
20+
<h1>
21+
{n.name}
22+
{/* {(n.get && n.get.tags) ||
23+
(n.post && n.post.tags) ||
24+
(n.put && n.put.tags)} */}
25+
</h1>
26+
</div>
1627
</div>
1728
</Layout>
1829
);
1930
};
2031

2132
export default apiPage;
33+
34+
export const query = graphql`
35+
query ApiQuery($name: String) {
36+
allPaths(filter: { name: { in: [$name] } }) {
37+
edges {
38+
node {
39+
internal {
40+
contentDigest
41+
}
42+
name
43+
get {
44+
x_linode_grant
45+
summary
46+
description
47+
operationId
48+
x_linode_cli_action
49+
x_linode_cli_skip
50+
x_linode_redoc_load_ids
51+
x_linode_cli_command
52+
tags
53+
}
54+
post {
55+
x_linode_grant
56+
summary
57+
description
58+
operationId
59+
x_linode_cli_action
60+
x_linode_cli_command
61+
x_linode_charge
62+
x_linode_cli_skip
63+
}
64+
put {
65+
x_linode_grant
66+
summary
67+
description
68+
operationId
69+
x_linode_cli_action
70+
x_linode_cli_skip
71+
}
72+
}
73+
}
74+
}
75+
}
76+
`;
77+
78+
// export default apiPage;

0 commit comments

Comments
 (0)