style: auto-format with Prettier (#20)

style: auto-format with Prettier
This commit is contained in:
Jean-Philippe Sirois
2019-07-29 03:27:56 -04:00
committed by GitHub
+12 -12
View File
@@ -1,8 +1,8 @@
const { graphql } = require('gatsby'); const { graphql } = require("gatsby")
const { createFilePath } = require("gatsby-source-filesystem"); const { createFilePath } = require("gatsby-source-filesystem")
const path = require(`path`) const path = require(`path`)
const usersEndpoint = (id) => `https://discordapp.com/api/guilds/${id}/members`; const usersEndpoint = id => `https://discordapp.com/api/guilds/${id}/members`
const fetchUsers = () => { const fetchUsers = () => {
// Fetch user data from discord using bot token here // Fetch user data from discord using bot token here
@@ -13,7 +13,7 @@ const createDocs = async ({ createPage, graphql }) => {
const result = await graphql(` const result = await graphql(`
{ {
allFile(filter: {sourceInstanceName: {eq: "docs"}}) { allFile(filter: { sourceInstanceName: { eq: "docs" } }) {
edges { edges {
node { node {
relativePath relativePath
@@ -27,7 +27,7 @@ const createDocs = async ({ createPage, graphql }) => {
} }
} }
} }
`); `)
if (result.errors) { if (result.errors) {
return Promise.reject(result.errors) return Promise.reject(result.errors)
@@ -35,28 +35,28 @@ const createDocs = async ({ createPage, graphql }) => {
return result.data.allFile.edges.forEach(({ node }) => { return result.data.allFile.edges.forEach(({ node }) => {
createPage({ createPage({
path: path.join('docs', node.relativePath), path: path.join("docs", node.relativePath),
component: languageDocs, component: languageDocs,
context: { context: {
file: node.relativePath file: node.relativePath,
}, },
}) })
}) })
} }
exports.onCreateNode = async ({ node, getNode, actions }) => { exports.onCreateNode = async ({ node, getNode, actions }) => {
const { createPage, createNodeField } = actions; const { createPage, createNodeField } = actions
if (node.internal.type === "MarkdownRemark") { if (node.internal.type === "MarkdownRemark") {
const slug = createFilePath({ node, getNode, basePath: "src/content/docs" }) const slug = createFilePath({ node, getNode, basePath: "src/content/docs" })
createNodeField({ createNodeField({
node, node,
name: "slug", name: "slug",
value: slug value: slug,
}); })
} }
} }
exports.createPages = ({ actions, graphql }) => { exports.createPages = ({ actions, graphql }) => {
const { createPage } = actions const { createPage } = actions
return createDocs({ createPage, graphql }); return createDocs({ createPage, graphql })
} }