Skip to content

Commit e9b06fa

Browse files
committed
refactor: clean up layouts, mainfest plugin
1 parent dee1315 commit e9b06fa

15 files changed

+98
-182
lines changed

config.js

-19
Original file line numberDiff line numberDiff line change
@@ -263,25 +263,6 @@ const config = {
263263
docsLocation: 'https://github.com/qri-io/website/blob/master/content',
264264
favicon: 'https://graphql-engine-cdn.hasura.io/img/hasura_icon_black.svg'
265265
},
266-
pwa: {
267-
enabled: false, // disabling this will also remove the existing service worker.
268-
manifest: {
269-
name: 'Gatsby Gitbook Starter',
270-
short_name: 'GitbookStarter',
271-
start_url: '/',
272-
background_color: '#6b37bf',
273-
theme_color: '#6b37bf',
274-
display: 'standalone',
275-
crossOrigin: 'use-credentials',
276-
icons: [
277-
{
278-
src: 'src/pwa-512.png',
279-
sizes: '512x512',
280-
type: 'image/png'
281-
}
282-
]
283-
}
284-
},
285266
docsSections,
286267
processCrumbs
287268
}

gatsby-config.js

+17-22
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,7 @@ const plugins = [
2121
'gatsby-plugin-netlify',
2222
'gatsby-plugin-sitemap',
2323
'gatsby-plugin-sharp',
24-
{
25-
resolve: 'gatsby-plugin-layout',
26-
options: {
27-
component: require.resolve('./src/layouts/index.js')
28-
}
29-
},
24+
'gatsby-plugin-layout',
3025
'gatsby-plugin-emotion',
3126
'gatsby-plugin-remove-trailing-slashes',
3227
'gatsby-plugin-react-helmet',
@@ -48,7 +43,7 @@ const plugins = [
4843
resolve: 'gatsby-plugin-mdx',
4944
options: {
5045
defaultLayouts: {
51-
pages: require.resolve('./src/layouts/markdown-page.js')
46+
pages: require.resolve('./src/components/markdown-page.js')
5247
},
5348
gatsbyRemarkPlugins: [
5449
{
@@ -85,24 +80,24 @@ const plugins = [
8580
options: {
8681
useAutoGen: true
8782
}
88-
}
89-
]
90-
91-
// check and add pwa functionality
92-
if (config.pwa && config.pwa.enabled && config.pwa.manifest) {
93-
plugins.push({
83+
},
84+
{
9485
resolve: 'gatsby-plugin-manifest',
95-
options: { ...config.pwa.manifest }
96-
})
97-
plugins.push({
98-
resolve: 'gatsby-plugin-offline',
9986
options: {
100-
appendScript: require.resolve('./src/custom-sw-code.js')
87+
name: 'Qri.io',
88+
short_name: 'Qri.io',
89+
icons: [{
90+
src: 'google-touch-icon.png',
91+
sizes: '512x512'
92+
}],
93+
background_color: '#ffffff',
94+
theme_color: '#ffffff',
95+
display: 'fullscreen'
10196
}
102-
})
103-
} else {
104-
plugins.push('gatsby-plugin-remove-serviceworker')
105-
}
97+
98+
}
99+
]
100+
106101
module.exports = {
107102
pathPrefix: config.gatsby.pathPrefix,
108103
siteMetadata: {

gatsby-node.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ exports.createPages = ({ graphql, actions }) => {
7474
result.data.allMdx.edges.forEach(({ node }) => {
7575
createPage({
7676
path: node.fields.slug ? node.fields.slug : '/',
77-
component: path.resolve('./src/layouts/docs.js'),
77+
component: path.resolve('./src/components/DocsContent.js'),
7878
context: {
7979
id: node.fields.id,
80-
layout: 'docs'
80+
layout: 'docs',
81+
faqPage: node.fields.slug === '/docs/faq'
8182
}
8283
})
8384
})
@@ -93,10 +94,11 @@ exports.createPages = ({ graphql, actions }) => {
9394
if (d.items) {
9495
createPage({
9596
path: d.path,
96-
component: path.resolve('./src/layouts/DocsSectionLandingPageLayout.js'),
97+
component: path.resolve('./src/components/DocsSectionLandingPage.js'),
9798
context: {
9899
sectionInfo: d,
99-
colorClass
100+
colorClass,
101+
layout: 'docsSectionLandingPage'
100102
}
101103
})
102104

netlify.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[build]
22
publish = "public"
3-
command = "npm run build"
3+
command = "gatsby build --prefix-paths"

src/components/DocsContent.js

+30
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react'
22
import MDXRenderer from 'gatsby-plugin-mdx/mdx-renderer'
33
import { MDXProvider } from '@mdx-js/react'
4+
import { graphql } from 'gatsby'
45

56
import mdxComponents from './mdxComponents'
67
import DocsFooter from './DocsFooter'
@@ -52,4 +53,33 @@ const DocsContent = (props) => {
5253
)
5354
}
5455

56+
export const pageQuery = graphql`
57+
query($id: String!) {
58+
site {
59+
siteMetadata {
60+
title
61+
docsLocation
62+
}
63+
}
64+
mdx(fields: { id: { eq: $id } }) {
65+
fields {
66+
id
67+
title
68+
slug
69+
}
70+
body
71+
tableOfContents
72+
parent {
73+
... on File {
74+
relativePath
75+
}
76+
}
77+
frontmatter {
78+
metaTitle
79+
metaDescription
80+
}
81+
}
82+
}
83+
`
84+
5585
export default DocsContent

src/components/DocsSectionLandingPage.js

+32-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
11
import React from 'react'
2+
import { graphql } from 'gatsby'
23
import classNames from 'classnames'
34

45
import DocsContentWide from './DocsContentWide'
56
import { calculateTreeData } from './sidebar/tree'
67
import DocsCards from './DocsCards'
78
import BreadCrumbs from '../components/BreadCrumbs'
89

9-
const DocsSectionLandingPage = ({ docsSectionInfo, allMdx, colorClass, crumbs }) => {
10+
const DocsSectionLandingPage = (props) => {
11+
const { data, pageContext } = props
12+
const { allMdx } = data
13+
14+
const { sectionInfo, colorClass, breadcrumb } = pageContext
15+
const { crumbs } = breadcrumb
16+
// traverse config.docsSections to locate the match
17+
return (
18+
<DocsSectionPage docsSectionInfo={sectionInfo} allMdx={allMdx} colorClass={colorClass} crumbs={crumbs} />
19+
)
20+
}
21+
22+
export default DocsSectionLandingPage
23+
24+
const DocsSectionPage = ({ docsSectionInfo, allMdx, colorClass, crumbs }) => {
1025
const tree = calculateTreeData(docsSectionInfo.items, allMdx.edges)
1126

1227
const topLevelItems = tree.filter(d => !d.items)
@@ -33,4 +48,19 @@ const DocsSectionLandingPage = ({ docsSectionInfo, allMdx, colorClass, crumbs })
3348
)
3449
}
3550

36-
export default DocsSectionLandingPage
51+
// pagequery to get data for this section
52+
export const pageQuery = graphql`
53+
query {
54+
allMdx(filter: {fileAbsolutePath: {regex: "\\/docs/"}}) {
55+
edges {
56+
node {
57+
fields {
58+
slug
59+
title
60+
description
61+
}
62+
}
63+
}
64+
}
65+
}
66+
`

src/components/index.js

-11
This file was deleted.
File renamed without changes.

src/components/standard-layout.js

-12
This file was deleted.

src/components/themeProvider.js

-15
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react'
2-
import { graphql } from 'gatsby'
32

43
import DocsColumns from '../components/DocsColumns'
54
import DocsContent from '../components/DocsContent'
@@ -25,7 +24,7 @@ const DocsLayout = (props) => {
2524
}
2625

2726
// special handling for FAQ, a markdown docs page with no sidebar
28-
if (props.path === '/docs/faq') {
27+
if (props.pageContext.faqPage) {
2928
leftSidebar = false
3029
}
3130

@@ -35,42 +34,13 @@ const DocsLayout = (props) => {
3534
}
3635

3736
return (
38-
<>
37+
<div className='docs-content-layout'>
3938
<DocsHeader {...props} />
4039
<DocsColumns {...props} leftSidebar={leftSidebar} rightSidebar={rightSidebar}>
4140
{content}
4241
</DocsColumns>
43-
</>
42+
</div>
4443
)
4544
}
4645

47-
export const pageQuery = graphql`
48-
query($id: String!) {
49-
site {
50-
siteMetadata {
51-
title
52-
docsLocation
53-
}
54-
}
55-
mdx(fields: { id: { eq: $id } }) {
56-
fields {
57-
id
58-
title
59-
slug
60-
}
61-
body
62-
tableOfContents
63-
parent {
64-
... on File {
65-
relativePath
66-
}
67-
}
68-
frontmatter {
69-
metaTitle
70-
metaDescription
71-
}
72-
}
73-
}
74-
`
75-
7646
export default DocsLayout

src/layouts/DocsSectionLandingPageLayout.js

-35
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)