-
-
Notifications
You must be signed in to change notification settings - Fork 314
/
mainPage.ts
91 lines (78 loc) · 3.47 KB
/
mainPage.ts
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
import qs from 'querystring';
const examplesMeta = [];
export function addToMainPage(example: any) {
examplesMeta.push(example);
}
function renderExamplesLinks() {
const examplesHtml = examplesMeta.map((meta) => {
const titleHtml = `<h4>
${meta.title}
${
meta.github
? `<small><a href="${meta.github}" target="_blank">GitHub <span class="glyphicon glyphicon-new-window"></span></a></small>`
: ''
}
</h4>`;
let descriptionHtml = '';
if (meta.description) {
descriptionHtml = `<p>${meta.description}</p>`;
}
const queries = meta.queries.map((queryData) => {
return `<b><a href="${meta.uri}/?query=${qs.escape(queryData.query)}" target="_blank">${
queryData.title
}</a></b>`;
});
queries.push(
`<b><a href="${meta.uri}" target="_blank">GraphQL Playground</a> (improved GraphiQL IDE)</b>`
);
queries.push(
`<b><a href="${meta.uri}-altair" target="_blank">Altair</a> (improved GraphiQL IDE)</b>`
);
queries.push(
`<b><a href="${meta.uri}-voyager" target="_blank">Voyager</a> (visual inspection tool)</b>`
);
const queriesHtml = `<ul><li>${queries.join('</li><li>')}</li></ul>`;
return `${titleHtml}${descriptionHtml}${queriesHtml}`;
});
return `<ol><li>${examplesHtml.join('</li><li>')}</li></ol>`;
}
export function mainPage() {
return `
<html>
<head>
<title>GraphQL-Compose examples</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
</head>
<body>
<div class="container">
<h1>GraphQL-Compose examples</h1>
${renderExamplesLinks()}
<br /><br /><br />
<h3>Source code:</h3>
<a href="https://github.com/nodkz/graphql-compose-examples" target="_blank">https://github.com/nodkz/graphql-compose-examples</a>
<h3>Used packages:</h3>
<a href="https://github.com/nodkz/graphql-compose" target="_blank">https://github.com/nodkz/graphql-compose</a>
<br/>
<a href="https://github.com/nodkz/graphql-compose-mongoose" target="_blank">https://github.com/nodkz/graphql-compose-mongoose</a>
<br/>
<a href="https://github.com/nodkz/graphql-compose-relay" target="_blank">https://github.com/nodkz/graphql-compose-relay</a>
<br/>
<a href="https://github.com/nodkz/graphql-compose-connection" target="_blank">https://github.com/nodkz/graphql-compose-connection</a>
<br/>
<a href="https://github.com/nodkz/graphql-compose-elasticsearch" target="_blank">https://github.com/nodkz/graphql-compose-elasticsearch</a>
<br/>
<a href="https://github.com/graphql-compose/graphql-compose-aws" target="_blank">https://github.com/graphql-compose/graphql-compose-aws</a>
</div>
<br /><br /><br /><br /><br />
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-83022112-1', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>
`;
}