chore: rename docs to resources

This commit is contained in:
Jean-Philippe Sirois
2019-07-29 20:48:30 -04:00
parent a833613b21
commit 8f771e194e
20 changed files with 50 additions and 50 deletions
+3 -3
View File
@@ -15,7 +15,7 @@ The official website for [The Programmer's Hangout](https://discord.gg/programmi
The site is built with [Gatsby](https://github.com/gatsbyjs/gatsby) which is used to leverage the power of React while The site is built with [Gatsby](https://github.com/gatsbyjs/gatsby) which is used to leverage the power of React while
allowing for static asset generation along with improved SEO. allowing for static asset generation along with improved SEO.
**This site and docs is still a work-in-progress and subject to change** **This site and resources is still a work-in-progress and subject to change**
### Setup ### Setup
@@ -29,7 +29,7 @@ allowing for static asset generation along with improved SEO.
If you're not familiar with Gatsby or React, you can still contribute by adding resources for languages you _are_ familiar with. If you're not familiar with Gatsby or React, you can still contribute by adding resources for languages you _are_ familiar with.
The list of resources can be found [here](/src/content/docs) The list of resources can be found [here](/src/content/resources)
#### Adding a new resource #### Adding a new resource
@@ -63,4 +63,4 @@ external_resources:
some content here some content here
``` ```
You can look at other resources like [this one](/src/content/docs/javascript/promises/intro.md) for reference when creating your own. We use [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) as the date format to confuse both Americans and Europeans an equal amount. You can look at other resources like [this one](/src/content/resources/javascript/promises/intro.md) for reference when creating your own. We use [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) as the date format to confuse both Americans and Europeans an equal amount.
+2 -2
View File
@@ -44,8 +44,8 @@ module.exports = {
{ {
resolve: `gatsby-source-filesystem`, resolve: `gatsby-source-filesystem`,
options: { options: {
name: `docs`, name: `resources`,
path: `${__dirname}/src/content/docs`, path: `${__dirname}/src/content/resources`,
}, },
}, },
`gatsby-transformer-sharp`, `gatsby-transformer-sharp`,
+7 -7
View File
@@ -26,12 +26,12 @@ const validateResourceArticle = node => {
} }
} }
const createDocs = async ({ createPage, graphql }) => { const createResources = async ({ createPage, graphql }) => {
const languageDocs = path.resolve(`src/templates/languagePost.tsx`) const languageResources = path.resolve(`src/templates/languagePost.tsx`)
const result = await graphql(` const result = await graphql(`
query FetchDocs { query FetchResources {
allFile(filter: { sourceInstanceName: { eq: "docs" } }) { allFile(filter: { sourceInstanceName: { eq: "resources" } }) {
edges { edges {
node { node {
relativePath relativePath
@@ -47,8 +47,8 @@ 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("resources", node.relativePath),
component: languageDocs, component: languageResources,
context: { context: {
file: node.relativePath, file: node.relativePath,
}, },
@@ -78,5 +78,5 @@ exports.onCreateNode = async ({ node, getNode, actions }) => {
exports.createPages = ({ actions, graphql }) => { exports.createPages = ({ actions, graphql }) => {
const { createPage } = actions const { createPage } = actions
return createDocs({ createPage, graphql }) return createResources({ createPage, graphql })
} }
+1 -1
View File
@@ -23,7 +23,7 @@ export function Header() {
<MenuItem to="/">rules</MenuItem> <MenuItem to="/">rules</MenuItem>
<MenuItem to="/">faq</MenuItem> <MenuItem to="/">faq</MenuItem>
<MenuItem to="/">hotbot</MenuItem> <MenuItem to="/">hotbot</MenuItem>
<MenuItem to="/docs">documentation</MenuItem> <MenuItem to="/resources">resources</MenuItem>
<MenuItem to="/">tech spotlight</MenuItem> <MenuItem to="/">tech spotlight</MenuItem>
</SC.Menu> </SC.Menu>
</SC.InnerWrapper> </SC.InnerWrapper>
@@ -9,11 +9,11 @@ import React, { PropsWithChildren } from "react"
import { useStaticQuery, graphql } from "gatsby" import { useStaticQuery, graphql } from "gatsby"
import { GlobalStyles } from "../../globalStyles" import { GlobalStyles } from "../../globalStyles"
import { DocsSidebar } from "../DocsSidebar" import { ResourcesSidebar } from "../ResourcesSidebar"
import { Footer } from "../Footer" import { Footer } from "../Footer"
import * as SC from "./styles" import * as SC from "./styles"
export function DocsLayout({ children }: PropsWithChildren<{}>) { export function ResourcesLayout({ children }: PropsWithChildren<{}>) {
const data = useStaticQuery(graphql` const data = useStaticQuery(graphql`
query { query {
site { site {
@@ -28,7 +28,7 @@ export function DocsLayout({ children }: PropsWithChildren<{}>) {
<div> <div>
<GlobalStyles /> <GlobalStyles />
<SC.Main> <SC.Main>
<DocsSidebar /> <ResourcesSidebar />
<SC.MainContent> <SC.MainContent>
<h1>{data.site.siteMetadata.title}</h1> <h1>{data.site.siteMetadata.title}</h1>
{children} {children}
@@ -31,15 +31,15 @@ export interface IFileQuery {
} }
} }
export interface IAllDocsQuery { export interface IAllResourcesQuery {
allFile: { allFile: {
edges: IFileQuery[] edges: IFileQuery[]
} }
} }
const ALL_DOCS = graphql` const ALL_RESOURCES = graphql`
query { query {
allFile(filter: { sourceInstanceName: { eq: "docs" } }) { allFile(filter: { sourceInstanceName: { eq: "resources" } }) {
edges { edges {
node { node {
relativePath relativePath
@@ -85,13 +85,13 @@ function Folder({ item }: { item: IFolder }) {
) )
} }
export function DocsSidebar() { export function ResourcesSidebar() {
const docs = useStaticQuery<IAllDocsQuery>(ALL_DOCS) const resources = useStaticQuery<IAllResourcesQuery>(ALL_RESOURCES)
const tree = useBuildTree(docs) const tree = useBuildTree(resources)
return ( return (
<SC.DocsSidebarWrapper> <SC.ResourcesSidebarWrapper>
{tree.map(node => plantTree(node))} {tree.map(node => plantTree(node))}
</SC.DocsSidebarWrapper> </SC.ResourcesSidebarWrapper>
) )
} }
@@ -1,7 +1,7 @@
import styled from "styled-components" import styled from "styled-components"
import { Link } from "gatsby" import { Link } from "gatsby"
export const DocsSidebarWrapper = styled.div` export const ResourcesSidebarWrapper = styled.div`
box-sizing: border-box; box-sizing: border-box;
padding: 0 16px; padding: 0 16px;
flex: 0 0 300px; flex: 0 0 300px;
@@ -5,13 +5,13 @@ import {
IFileOrFolder, IFileOrFolder,
IFile, IFile,
IFolder, IFolder,
IAllDocsQuery, IAllResourcesQuery,
IFileQuery, IFileQuery,
} from "./index" } from "./index"
function traverse( function traverse(
[head, ...tail]: string[], [head, ...tail]: string[],
basePath = "/docs" basePath = "/resources"
): IFileOrFolder { ): IFileOrFolder {
const path = basePath + "/" + head const path = basePath + "/" + head
const isFile = !tail.length const isFile = !tail.length
@@ -83,8 +83,8 @@ function join([head, ...tail]: IFileOrFolder[]): IFileOrFolder[] {
return [current, ...join(remaining)] return [current, ...join(remaining)]
} }
export default function useBuildTree(docs: IAllDocsQuery) { export default function useBuildTree(resources: IAllResourcesQuery) {
const objects = docs.allFile.edges.map(({ node: file }: IFileQuery) => const objects = resources.allFile.edges.map(({ node: file }: IFileQuery) =>
traverse(file.relativePath.split("/")) traverse(file.relativePath.split("/"))
) )
@@ -1,14 +1,14 @@
import React, { PropsWithChildren } from "react" import React, { PropsWithChildren } from "react"
import * as SC from "./styles" import * as SC from "./styles"
export interface DocsSidebarSectionProps { export interface ResourcesSidebarSectionProps {
readonly title: string readonly title: string
} }
export function DocsSidebarSection({ export function ResourcesSidebarSection({
title, title,
children, children,
}: PropsWithChildren<DocsSidebarSectionProps>) { }: PropsWithChildren<ResourcesSidebarSectionProps>) {
return ( return (
<div> <div>
<SC.SidebarTitle>{title}</SC.SidebarTitle> <SC.SidebarTitle>{title}</SC.SidebarTitle>
-15
View File
@@ -1,15 +0,0 @@
import React from "react"
import { DocsLayout } from "../components/DocsLayout"
import { SEO } from "../components/SEO"
function DocsPage() {
return (
<DocsLayout>
<SEO title="Docs" />
the docs
</DocsLayout>
)
}
export default DocsPage
+15
View File
@@ -0,0 +1,15 @@
import React from "react"
import { ResourcesLayout } from "../components/ResourcesLayout"
import { SEO } from "../components/SEO"
function ResourcesPage() {
return (
<ResourcesLayout>
<SEO title="Resources" />
the resources
</ResourcesLayout>
)
}
export default ResourcesPage
+3 -3
View File
@@ -2,17 +2,17 @@ import React from "react"
import { graphql } from "gatsby" import { graphql } from "gatsby"
import { Markdown } from "../components/Markdown" import { Markdown } from "../components/Markdown"
import { SEO } from "../components/SEO" import { SEO } from "../components/SEO"
import { DocsLayout } from "../components/DocsLayout" import { ResourcesLayout } from "../components/ResourcesLayout"
// @todo maybe find alternative type for data // @todo maybe find alternative type for data
function LanguagePost({ data }: any) { function LanguagePost({ data }: any) {
const { html, frontmatter } = data.file.post const { html, frontmatter } = data.file.post
console.log(data) console.log(data)
return ( return (
<DocsLayout> <ResourcesLayout>
<SEO title={frontmatter.title} /> <SEO title={frontmatter.title} />
<Markdown content={html} /> <Markdown content={html} />
</DocsLayout> </ResourcesLayout>
) )
} }