Skip to content

Commit 191bd1e

Browse files
committed
Initial commit of FAQ page
1 parent 24f7de4 commit 191bd1e

File tree

5 files changed

+75
-1
lines changed

5 files changed

+75
-1
lines changed

src/assets/css/_css/docs.less

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@
162162
}
163163
}
164164

165+
.faq-questions::before {
166+
content: "\A";
167+
white-space: pre;
168+
}
169+
165170
img {
166171
max-width: 100%;
167172
}

src/components/FAQLayout/index.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from "react"
2+
import { Link } from "gatsby"
3+
import Marked from '../Marked'
4+
import { toSlug } from '../../utils/slug'
5+
6+
interface Props {
7+
title: string
8+
questions: string
9+
rawMarkdownBody: string
10+
}
11+
12+
const index = ({ title, questions, rawMarkdownBody }: Props) => {
13+
return (
14+
<section>
15+
<div className="documentationContent">
16+
<div className="inner-content">
17+
<h1>{title}</h1>
18+
{questions && (
19+
<div>
20+
{questions
21+
.split(',')
22+
.map(question => (
23+
<Link className="faq-questions" key={question} to={`#${toSlug( question )}`}>
24+
{question}
25+
</Link>
26+
))
27+
}
28+
</div>
29+
)}
30+
<Marked>{rawMarkdownBody}</Marked>
31+
</div>
32+
</div>
33+
</section>
34+
)
35+
}
36+
37+
export default index

src/components/HeaderLinks/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const links: LinkItem[] = [
1111
{ section: "learn", text: "Learn", href: "/learn/" },
1212
{ section: "code", text: "Code", href: "/code/" },
1313
{ section: "community", text: "Community", href: "/community/" },
14+
{ section: "faq", text: "FAQ", href: "/faq/" },
1415
{
1516
section: "spec",
1617
text: "Spec",

src/content/faq/General.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: Frequently Asked Questions (FAQ)
3+
layout: faq
4+
category: General
5+
permalink: /faq/
6+
questions: Why should I use GraphQL?,Is GraphQL a database language like SQL?,Does GraphQL replace REST?,How can I learn GraphQL?,Is GraphQL frontend or backend?,Does GraphQL replace Redux or other state management libraries?,Is GraphQL only for React or JavaScript developers?,What is a GraphQL client and why would I use one?,What is the GraphQL Foundation?,How can I contribute to the GraphQL specification?
7+
---
8+
9+
## Why should I use GraphQL?
10+
11+
## Is GraphQL a database language like SQL?
12+
13+
## Does GraphQL replace REST?
14+
15+
## How can I learn GraphQL?
16+
17+
## Is GraphQL frontend or backend?
18+
19+
## Does GraphQL replace Redux or other state management libraries?
20+
21+
## Is GraphQL only for React or JavaScript developers?
22+
23+
## What is a GraphQL client and why would I use one?
24+
25+
## What is the GraphQL Foundation?
26+
27+
## How can I contribute to the GraphQL specification?

src/templates/doc.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Layout from "../components/Layout"
44
import DocsLayout from "../components/DocsLayout"
55
import BlogLayout from '../components/BlogLayout';
66
import CodeLayout from "../components/CodeLayout";
7+
import FAQLayout from "../components/FAQLayout";
78

89
interface Props {
910
data: any
@@ -14,12 +15,13 @@ const layoutMap: any = {
1415
docs: DocsLayout,
1516
blog: BlogLayout,
1617
code: CodeLayout,
18+
faq: FAQLayout,
1719
}
1820

1921
const Blog = ({ data, pageContext }: Props) => {
2022
const {
2123
doc: {
22-
frontmatter: { title, date, permalink, byline, guestBio, layout },
24+
frontmatter: { title, date, permalink, byline, guestBio, layout, questions },
2325
rawMarkdownBody,
2426
},
2527
nextDoc,
@@ -33,6 +35,7 @@ const Blog = ({ data, pageContext }: Props) => {
3335
permalink={permalink}
3436
byline={byline}
3537
guestBio={guestBio}
38+
questions={questions}
3639
rawMarkdownBody={rawMarkdownBody}
3740
nextDoc={nextDoc}
3841
sideBarData={pageContext.sideBarData}
@@ -52,6 +55,7 @@ export const query = graphql`
5255
guestBio
5356
sublinks
5457
layout
58+
questions
5559
}
5660
id
5761
rawMarkdownBody

0 commit comments

Comments
 (0)