Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Tutorials Section #42

Merged
merged 37 commits into from
Apr 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ab38d71
Add blank `TutorialPage` component
ceolson01 Mar 31, 2019
6eeda4b
Add basic `gatsby-transform-md-tutorials` plugin
ceolson01 Mar 31, 2019
299b8ae
Add tutorials to `gatsby-config`
ceolson01 Mar 31, 2019
1ccd281
Fix tutorials `md` plugin
ceolson01 Mar 31, 2019
c2b0f47
Add basic `singleTutorial` graphql query fragment
ceolson01 Mar 31, 2019
c6f36c9
Add page query using tutorialId from page context & fragment
ceolson01 Mar 31, 2019
929e4e3
Add typings for `Tutorial` & query results
ceolson01 Mar 31, 2019
9267109
Basic tutorial content handling
ceolson01 Mar 31, 2019
d598926
Add additional frontmatter fields
ceolson01 Mar 31, 2019
5587b07
Rehype elements with core components
ceolson01 Mar 31, 2019
8e19e27
Fix date type for query results
ceolson01 Mar 31, 2019
11bdcc9
Add queried content to tutorial template
ceolson01 Mar 31, 2019
eb90d3d
Move `SupportCta` to parts dir for reusability
ceolson01 Mar 31, 2019
a1f64e8
Refactor `DevRelCta` into its own component for reusability
ceolson01 Mar 31, 2019
8cf2aec
Add `editUrl` to nodes
ceolson01 Mar 31, 2019
0da9ab0
Add `editUrl` & `DevRelCta` to `TutorialPage`
ceolson01 Mar 31, 2019
bfe4715
Add base `Tutorials` page template
ceolson01 Mar 31, 2019
20f8fa3
Add `tutorials` page
ceolson01 Mar 31, 2019
87a0e27
Add slug field
ceolson01 Mar 31, 2019
2f59aad
Query new `slug` field, use for links
ceolson01 Mar 31, 2019
ed7f2d5
Add tutorials list
ceolson01 Apr 1, 2019
49737c1
New button themes, use in tutorials
ceolson01 Apr 2, 2019
ab9bdec
Improve SEO typing, refactor to functional component
ceolson01 Apr 2, 2019
d72b15d
Add `excerpt` to tutorial markdown query & schema
ceolson01 Apr 2, 2019
e264d0d
Add `SEO` to tutorial page with excerpt
ceolson01 Apr 2, 2019
9eb2b48
Add `SEO` to tutorials list
ceolson01 Apr 2, 2019
cfd297a
Add appropriate padding for tutorial list items
ceolson01 Apr 2, 2019
c4cd8be
Remove `format` prop - should not have been there
ceolson01 Apr 2, 2019
1a69ab4
Format date from frontmatter
ceolson01 Apr 2, 2019
6b96dce
Prettylink & icon hover colors
ceolson01 Apr 2, 2019
816cd89
Use new pattern with reduced opacity
ceolson01 Apr 2, 2019
da5486a
Center logo in container
ceolson01 Apr 2, 2019
81a478a
Fix hover states for dropdown menu cta
ceolson01 Apr 2, 2019
15d2660
Make `SupportCTA` reusable; reuse it
ceolson01 Apr 2, 2019
e8582af
Update plugins to only transform particular source instances
ceolson01 Apr 2, 2019
676d15d
Use improved version of social gitter with neg. space
ceolson01 Apr 2, 2019
a6e38d3
Remove unnecessary button, link to tutorials repo
ceolson01 Apr 4, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ const sourcePlugins = {
path: path.resolve(__dirname, '..', 'tailor', 'docs'),
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'colonyTutorials',
path: path.resolve(__dirname, '..', 'colonyTutorials', 'tutorials'),
}
},
// {
// resolve: 'gatsby-source-filesystem',
// options: {
Expand Down Expand Up @@ -173,6 +180,17 @@ module.exports = {
}
}
},
{
resolve: 'gatsby-transform-md-tutorials',
options: {
slugPrefix: 'tutorials',
langConfig: {
langs: CONFIGURED_LOCALES,
defaultLangKey,
prefixDefaultLangKey,
}
}
},
{
resolve: 'gatsby-transformer-remark',
options: {
Expand Down
7 changes: 3 additions & 4 deletions plugins/gatsby-transform-md-docs/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@ exports.onCreateNode = ({ node, actions, getNode }, nodeOptions) => {
createNodeField,
createParentChildLink,
} = actions

const { langConfig: { defaultLangKey, prefixDefaultLangKey } } = nodeOptions;
const { langConfig: { defaultLangKey, prefixDefaultLangKey }, projects: configuredProjects } = nodeOptions;

let projectNode
let sectionNode

if (node.base === 'doc.config.json') {
if (node.base === 'doc.config.json' && configuredProjects.includes(node.sourceInstanceName)) {
const { projectName, projectId } = getProjectInfo(node)
projectNode = getNode(projectId)
if (!projectNode) {
Expand Down Expand Up @@ -75,7 +74,7 @@ exports.onCreateNode = ({ node, actions, getNode }, nodeOptions) => {
projectNode.description = config.description
projectNode.descriptionTranslations = getProjectDescriptionTranslations(config);
projectNode.repoUrl = `https://github.com/JoinColony/${projectNode.name}`;
} else if (node.internal.type === 'MarkdownRemark') {
} else if (node.internal.type === 'MarkdownRemark' && configuredProjects.includes(getNode(node.parent).sourceInstanceName)) {
const sectionName = node.frontmatter.section

// If section does not exist in frontmatter we just return
Expand Down
104 changes: 104 additions & 0 deletions plugins/gatsby-transform-md-tutorials/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
const path = require('path');
const slugify = require('slugify');

const { TutorialNode } = require('./nodes');

const nodeQuery = `
{
tutorials: allTutorial {
edges {
node {
id
name
slug
fields {
markdownNodeId
}
}
}
}
}
`;

const onCreateNode = async ({ actions: { createNode, createNodeField }, getNode, node }, nodeOptions) => {
const { projects: configuredProjects } = nodeOptions;
if (node.internal.type === 'MarkdownRemark' && configuredProjects.includes(getNode(node.parent).sourceInstanceName)) {
const { langConfig: { defaultLangKey, prefixDefaultLangKey } } = nodeOptions;

let tutorialNode;
const { tutorialName, tutorialId } = getTutorialInfo(node);
tutorialNode = getNode(tutorialId);
if (!tutorialNode) {
tutorialNode = createTutorialNode(tutorialName, createNode, nodeOptions);
}
createNodeField({ node: tutorialNode, name: 'markdownNodeId', value: node.id });

const editUrl = getNodeEditUrl(getNode(node.parent))
createNodeField({
node: tutorialNode,
name: 'editUrl',
value: editUrl,
})
node.editUrl = editUrl;

if (!node.frontmatter.locale) {
node.frontmatter.locale = defaultLangKey;
}
const nodeLocale = node.frontmatter.locale;
const localeSlugPrefix = nodeLocale === defaultLangKey && !prefixDefaultLangKey ? '' : `${nodeLocale}/`;
// Add a slug as the TOC creation requires that (for linking)
node.slug = slugify(node.frontmatter.title, { lower: true })
// Slug for the actual page
createNodeField({
node: tutorialNode,
name: 'slug',
value: `/${localeSlugPrefix}${tutorialNode.slug}`,
})
}
};

const createPages = ({ graphql, actions: { createPage } }, nodeOptions) => {
return graphql(nodeQuery).then(({ data: { tutorials: { edges }} }) => {
edges.forEach(({ node: tutorial }) => {
createTutorialPage(tutorial, createPage, nodeOptions);
});
});
};

const createTutorialNode = (name, createNode, { slugPrefix }) => {
const tutorialNode = TutorialNode({
name,
slug: `${slugify(slugPrefix, { lower: true })}/${slugify(name, { lower: true })}`,
});
createNode(tutorialNode);
return tutorialNode;
};

const createTutorialPage = ({ slug, fields: { markdownNodeId } }, createPage, nodeOptions) => {
createPage({
path: slug,
component: path.resolve(__dirname, '..', '..', 'src', 'modules', 'pages', 'components', 'TutorialPage', 'TutorialPage.jsx'),
context: {
tutorialId: markdownNodeId,
},
});
};

const getNodeEditUrl = parent => {
// github sourced
if(parent && parent.githubEditPath) {
return `https://github.com/${parent.githubEditPath}`;
}
// filesystem sourced - assume master branch
const projectName = parent.sourceInstanceName;
return `https://github.com/JoinColony/${projectName}/edit/master/tutorials/${parent.relativePath}`;
};

const getTutorialInfo = node => {
const tutorialName = node.frontmatter.title;
const tutorialId = TutorialNode({ name: tutorialName }).id;
return { tutorialName, tutorialId };
};

exports.createPages = createPages;
exports.onCreateNode = onCreateNode;
1 change: 1 addition & 0 deletions plugins/gatsby-transform-md-tutorials/nodes/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exports.TutorialNode = require('./tutorial');
17 changes: 17 additions & 0 deletions plugins/gatsby-transform-md-tutorials/nodes/tutorial.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const createNodeHelpers = require('gatsby-node-helpers').default;

const { createNodeFactory, generateNodeId } = createNodeHelpers({
typePrefix: 'Tutorials',
});

const TUTORIAL_TYPE = 'Tutorial';

const TutorialNode = createNodeFactory(TUTORIAL_TYPE, node => {
node.id = generateNodeId(TUTORIAL_TYPE, node.name);
node.internal = {
type: TUTORIAL_TYPE,
};
return node;
});

module.exports = TutorialNode;
13 changes: 13 additions & 0 deletions plugins/gatsby-transform-md-tutorials/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "gatsby-transform-md-tutorials",
"version": "1.0.0",
"description": "",
"main": "gatsby-node.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"contributors": [
"Curtis Olson <[email protected]>"
],
"license": "ISC"
}
2 changes: 1 addition & 1 deletion src/modules/core/components/Button/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getMainClasses } from '~utils/css';
import styles from './Button.module.css';

type Appearance = {
theme?: 'primary' | 'reset',
theme?: 'primary' | 'primaryHollow' | 'reset',
};

type Props = {
Expand Down
37 changes: 24 additions & 13 deletions src/modules/core/components/Button/Button.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,40 @@
align-items: center;
border-radius: 4px;
display: inline-flex;
height: 45px;
font-size: 15px;
font-size: 16px;
justify-content: center;
font-family: 'Avenir Next Demi';
font-family: 'Avenir Next Light';
text-align: center;
transition: 0.2s;
}

.themePrimary {
.primaryBase {
composes: main;
background-color: rgb(105, 220, 210);
border: 2px solid rgb(105, 220, 210);
color: rgb(0, 40, 75);
border: 1px solid #289BDC;
min-width: 130px;
padding: 11px 15px;
padding: 3px 31px;
}

.themePrimary {
composes: primaryBase;
background-color: #289BDC;
color: #ffffff;
}

.themePrimary:hover {
background-color: transparent !important;
border: 2px solid rgb(105, 220, 210) !important;
box-shadow: none !important;
cursor: pointer !important;
text-decoration: none !important;
background-color: transparent;
color: #00284B;
}

.themePrimaryHollow {
composes: primaryBase;
background-color: transparent;
color: #00284B;
}

.themePrimaryHollow:hover {
background-color: #289BDC;
color: #ffffff;
}

.themeReset {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
text-align: left;
}

.heroLink {
display: block;
height: 82px;
}

.hero {
align-items: stretch;
border-radius: borderRadius;
Expand All @@ -21,7 +26,8 @@
border-radius: borderRadius;
box-shadow: boxShadow;
display: flex;
align-items: center
align-items: center;
justify-content: center;
}

.logo {
Expand Down
4 changes: 2 additions & 2 deletions src/modules/pages/components/Developers/Developers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { defineMessages } from 'react-intl';
import { Helmet } from 'react-helmet';

import SEO from '~parts/SEO';
import SupportCta from '~parts/SupportCta';

import CoreProducts from './CoreProducts';
import Hero from './Hero';
import OpenSource from './OpenSource';
import SupportCta from './SupportCta';

import styles from './Developers.module.css';

Expand Down Expand Up @@ -47,7 +47,7 @@ const Developers = ({ intl: { formatMessage } }: Props) => {
<Hero />
<CoreProducts />
<OpenSource />
<SupportCta />
<SupportCta withBackground />
</main>
</>
);
Expand Down
59 changes: 0 additions & 59 deletions src/modules/pages/components/Developers/SupportCta/SupportCta.jsx

This file was deleted.

Loading