Add Intro pages through markdown

This commit is contained in:
Stuart Taylor
2018-04-12 17:20:52 +01:00
committed by Mrugesh Mohapatra
parent dcb6378975
commit ca6748a477
28 changed files with 760 additions and 16 deletions

View File

@ -23,6 +23,14 @@ module.exports = {
source: buildChallenges$ source: buildChallenges$
} }
}, },
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'introductions',
path: path.resolve(__dirname, './src/introductions')
}
},
'gatsby-transformer-remark',
{ {
resolve: 'gatsby-plugin-google-fonts', resolve: 'gatsby-plugin-google-fonts',
options: { options: {

View File

@ -9,6 +9,7 @@ const classic = path.resolve(
__dirname, __dirname,
'./src/templates/Challenges/classic/Show.js' './src/templates/Challenges/classic/Show.js'
); );
const intro = path.resolve(__dirname, './src/templates/Introduction/Intro.js');
const views = { const views = {
// backend: BackEnd, // backend: BackEnd,
@ -33,6 +34,16 @@ exports.onCreateNode = function onCreateNode({ node, boundActionCreators }) {
// TODO: Normalise tests to { test: '', testString: ''}? // TODO: Normalise tests to { test: '', testString: ''}?
createNodeField({ node, name: 'tests', value: tests }); createNodeField({ node, name: 'tests', value: tests });
} }
if (node.internal.type === 'MarkdownRemark') {
const { frontmatter: { block, superBlock, title } } = node;
const slug = `/${dasherize(superBlock)}${
block ? `/${dasherize(block)}${title ? `/${dasherize(title)}` : ''}` : ''
}`;
createNodeField({ node, name: 'slug', value: slug });
}
}; };
exports.createPages = ({ graphql, boundActionCreators }) => { exports.createPages = ({ graphql, boundActionCreators }) => {
@ -60,6 +71,21 @@ exports.createPages = ({ graphql, boundActionCreators }) => {
} }
} }
} }
allMarkdownRemark {
edges {
node {
fields {
slug
}
frontmatter {
block
superBlock
title
}
html
}
}
}
} }
`).then(result => { `).then(result => {
if (result.errors) { if (result.errors) {
@ -93,6 +119,18 @@ exports.createPages = ({ graphql, boundActionCreators }) => {
}); });
}); });
// Create intro pages
result.data.allMarkdownRemark.edges.forEach(edge => {
const { fields: { slug } } = edge.node;
createPage({
path: slug,
component: intro,
context: {
slug
}
});
});
return; return;
}) })
); );

View File

@ -20,9 +20,10 @@
"gatsby-plugin-google-fonts": "^0.0.4", "gatsby-plugin-google-fonts": "^0.0.4",
"gatsby-plugin-react-helmet": "^2.0.8", "gatsby-plugin-react-helmet": "^2.0.8",
"gatsby-plugin-react-next": "^1.0.11", "gatsby-plugin-react-next": "^1.0.11",
"gatsby-source-filesystem": "^1.5.27", "gatsby-source-filesystem": "^1.5.29",
"gatsby-source-mongodb": "^1.5.19", "gatsby-source-mongodb": "^1.5.19",
"gatsby-transformer-json": "^1.0.16", "gatsby-transformer-json": "^1.0.16",
"gatsby-transformer-remark": "^1.7.39",
"jest": "^22.4.3", "jest": "^22.4.3",
"lodash": "^4.17.5", "lodash": "^4.17.5",
"loop-protect": "^2.1.6", "loop-protect": "^2.1.6",

View File

@ -1,6 +1,7 @@
--- ---
title: Introduction to the Basic Node and Express Challenges title: Introduction to the Basic Node and Express Challenges
block: Basic Node and Express block: Basic Node and Express
superBlock: APIs and Microservices
--- ---
## Introduction to the Basic Node and Express Challenges ## Introduction to the Basic Node and Express Challenges

View File

@ -1,6 +1,7 @@
--- ---
title: Introduction to the Managing Packages with npm Challenges title: Introduction to the Managing Packages with npm Challenges
block: Managing Packages with Npm block: Managing Packages with Npm
superBlock: APIs and Microservices
--- ---
## Introduction to the Managing Packages with npm Challenges ## Introduction to the Managing Packages with npm Challenges

View File

@ -1,6 +1,7 @@
--- ---
title: Introduction to the MongoDB and Mongoose Challenges title: Introduction to the MongoDB and Mongoose Challenges
block: MongoDB and Mongoose block: MongoDB and Mongoose
superBlock: APIs and Microservices
--- ---
## Introduction to the MongoDB and Mongoose Challenges ## Introduction to the MongoDB and Mongoose Challenges

View File

@ -1,6 +1,7 @@
--- ---
title: Introduction to the Data Visualization with D3 Challenges title: Introduction to the Data Visualization with D3 Challenges
block: Data Visualization with D3 block: Data Visualization with D3
superBlock: Data Visualization
--- ---
## Introduction to the Data Visualization with D3 Challenges ## Introduction to the Data Visualization with D3 Challenges

View File

@ -1,6 +1,7 @@
--- ---
title: Introduction to the JSON APIs and AJAX Challenges title: Introduction to the JSON APIs and AJAX Challenges
block: JSON APIs and Ajax block: JSON APIs and Ajax
superBlock: Data Visualization
--- ---
## Introduction to the JSON APIs and AJAX Challenges ## Introduction to the JSON APIs and AJAX Challenges

View File

@ -1,6 +1,7 @@
--- ---
title: Introduction to the Bootstrap Challenges title: Introduction to the Bootstrap Challenges
block: Bootstrap block: Bootstrap
superBlock: Front End Libraries
--- ---
## Introduction to the Bootstrap Challenges ## Introduction to the Bootstrap Challenges

View File

@ -1,6 +1,7 @@
--- ---
title: Introduction to jQuery title: Introduction to jQuery
block: jQuery block: jQuery
superBlock: Front End Libraries
--- ---
## Introduction to jQuery ## Introduction to jQuery

View File

@ -1,6 +1,7 @@
--- ---
title: Introduction to the Sass Challenges title: Introduction to the Sass Challenges
block: Sass block: Sass
superBlock: Front End Libraries
--- ---
## Introduction to the Sass Challenges ## Introduction to the Sass Challenges

View File

@ -1,6 +1,7 @@
--- ---
title: Introduction to Information Security with HelmetJS Challenges title: Introduction to Information Security with HelmetJS Challenges
block: Information Security with HelmetJS block: Information Security with HelmetJS
superBlock: Information Security and Quality Assurance
--- ---
## Introduction to Information Security with HelmetJS Challenges ## Introduction to Information Security with HelmetJS Challenges

View File

@ -1,6 +1,7 @@
--- ---
title: Introduction to Objects title: Introduction to Objects
block: Basic Data Structures block: Basic Data Structures
superBlock: JavaScript Algorithms and Data Structures
--- ---
## Introduction to Objects ## Introduction to Objects

View File

@ -1,6 +1,7 @@
--- ---
title: Introduction to JavaScript title: Introduction to JavaScript
block: Basic JavaScript block: Basic JavaScript
superBlock: JavaScript Algorithms and Data Structures
--- ---
## Introduction to JavaScript ## Introduction to JavaScript

View File

@ -1,6 +1,7 @@
--- ---
title: Introduction to the Debugging Challenges title: Introduction to the Debugging Challenges
block: Debugging block: Debugging
superBlock: JavaScript Algorithms and Data Structures
--- ---
## Introduction to the Debugging Challenges ## Introduction to the Debugging Challenges

View File

@ -1,6 +1,7 @@
--- ---
title: Introduction to the ES6 Challenges title: Introduction to the ES6 Challenges
block: ES6 block: ES6
superBlock: JavaScript Algorithms and Data Structures
--- ---
## Introduction to the ES6 Challenges ## Introduction to the ES6 Challenges

View File

@ -1,6 +1,7 @@
--- ---
title: Introduction to the Functional Programming Challenges title: Introduction to the Functional Programming Challenges
block: Functional Programming block: Functional Programming
superBlock: JavaScript Algorithms and Data Structures
--- ---
## Introduction to the Functional Programming Challenges ## Introduction to the Functional Programming Challenges

View File

@ -1,6 +1,7 @@
--- ---
title: Introduction to the Object Oriented Programming Challenges title: Introduction to the Object Oriented Programming Challenges
block: Object Oriented Programming block: Object Oriented Programming
superBlock: JavaScript Algorithms and Data Structures
--- ---
## Introduction to the Object Oriented Programming Challenges ## Introduction to the Object Oriented Programming Challenges

View File

@ -1,6 +1,7 @@
--- ---
title: Introduction to the Regular Expression Challenges title: Introduction to the Regular Expression Challenges
block: Regular Expressions block: Regular Expressions
superBlock: JavaScript Algorithms and Data Structures
--- ---
## Introduction to the Regular Expression Challenges ## Introduction to the Regular Expression Challenges

View File

@ -1,6 +1,7 @@
--- ---
title: Introduction to the Applied Accessibility Challenges title: Introduction to the Applied Accessibility Challenges
block: Applied Accessibility block: Applied Accessibility
superBlock: Responsive Web Design
--- ---
## Introduction to the Applied Accessibility Challenges ## Introduction to the Applied Accessibility Challenges

View File

@ -1,6 +1,7 @@
--- ---
title: Introduction to the Applied Visual Design Challenges title: Introduction to the Applied Visual Design Challenges
block: Applied Visual Design block: Applied Visual Design
superBlock: Responsive Web Design
--- ---
## Introduction to the Applied Visual Design Challenges ## Introduction to the Applied Visual Design Challenges

View File

@ -1,6 +1,7 @@
--- ---
title: Introduction to Basic CSS title: Introduction to Basic CSS
block: Basic CSS block: Basic CSS
superBlock: Responsive Web Design
--- ---
## Introduction to Basic CSS ## Introduction to Basic CSS

View File

@ -1,6 +1,7 @@
--- ---
title: Introduction to the CSS Flexbox Challenges title: Introduction to the CSS Flexbox Challenges
block: CSS Flexbox block: CSS Flexbox
superBlock: Responsive Web Design
--- ---
## Introduction to the CSS Flexbox Challenges ## Introduction to the CSS Flexbox Challenges

View File

@ -1,6 +1,7 @@
--- ---
title: Introduction to the CSS Grid Challenges title: Introduction to the CSS Grid Challenges
block: CSS Grid block: CSS Grid
superBlock: Responsive Web Design
--- ---
## Introduction to the CSS Grid Challenges ## Introduction to the CSS Grid Challenges

View File

@ -1,6 +1,7 @@
--- ---
title: Introduction to the Responsive Web Design Challenges title: Introduction to the Responsive Web Design Challenges
block: Responsive Web Design Principles block: Responsive Web Design Principles
superBlock: Responsive Web Design
--- ---
## Introduction to the Responsive Web Design Challenges ## Introduction to the Responsive Web Design Challenges

View File

@ -9,6 +9,15 @@ const FileType = PropTypes.shape({
tail: PropTypes.string tail: PropTypes.string
}); });
export const MarkdownRemark = PropTypes.shape({
html: PropTypes.string,
frontmatter: PropTypes.shape({
title: PropTypes.string,
block: PropTypes.string,
superBlock: PropTypes.string
})
});
export const ChallengeNode = PropTypes.shape({ export const ChallengeNode = PropTypes.shape({
block: PropTypes.string, block: PropTypes.string,
challengeType: PropTypes.number, challengeType: PropTypes.number,

View File

@ -0,0 +1,30 @@
/* global graphql */
import React from 'react';
import PropTypes from 'prop-types';
import { MarkdownRemark } from '../../redux/propTypes';
const propTypes = {
data: PropTypes.shape({
markdownRemark: MarkdownRemark
})
};
function IntroductionPage({ data: { markdownRemark } }) {
const { html } = markdownRemark;
return (
<div className='intro-layout' dangerouslySetInnerHTML={{ __html: html }} />
);
}
IntroductionPage.displayName = 'IntroductionPage';
IntroductionPage.propTypes = propTypes;
export default IntroductionPage;
export const query = graphql`
query IntroPageBySlug($slug: String!) {
markdownRemark(fields: { slug: { eq: $slug } }) {
html
}
}
`;

File diff suppressed because it is too large Load Diff