Merge pull request #37 from tchaffee/fix/stub-superblock-index-pages
Add superBlock intro pages
This commit is contained in:
parent
571209809c
commit
04a6a2026c
@ -21,7 +21,14 @@ exports.onCreateNode = function onCreateNode({ node, boundActionCreators }) {
|
||||
if (node.internal.type === 'MarkdownRemark') {
|
||||
const { frontmatter: { block, superBlock } } = node;
|
||||
|
||||
const slug = `/${dasherize(superBlock)}/${dasherize(block)}`;
|
||||
let slug = `/${dasherize(superBlock)}`;
|
||||
|
||||
// Without this condition the slug for superblocks ends up as something like
|
||||
// "/apis-and-microservice/undefined" and what we want instead is just
|
||||
// "/apis-and-microservice"
|
||||
if (typeof block !== 'undefined') {
|
||||
slug = slug + `/${dasherize(block)}`;
|
||||
}
|
||||
|
||||
createNodeField({ node, name: 'slug', value: slug });
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
---
|
||||
title: APIs and Microservices
|
||||
superBlock: APIs and Microservices
|
||||
---
|
||||
## Introduction to APIs and Microservices
|
||||
|
||||
This is a stub introduction for APIs and Microservices
|
@ -0,0 +1,7 @@
|
||||
---
|
||||
title: Data Visualization
|
||||
superBlock: Data Visualization
|
||||
---
|
||||
## Introduction to Data Visualization
|
||||
|
||||
This is a stub introduction for Data Visualization
|
@ -0,0 +1,7 @@
|
||||
---
|
||||
title: Front End Libraries
|
||||
superBlock: Front End Libraries
|
||||
---
|
||||
## Introduction to Front End Libraries
|
||||
|
||||
This is a stub introduction for Front End Libraries
|
@ -0,0 +1,7 @@
|
||||
---
|
||||
title: Information Security and Quality Assurance
|
||||
superBlock: Information Security and Quality Assurance
|
||||
---
|
||||
## Introduction to Information Security and Quality Assurance
|
||||
|
||||
This is a stub introduction for Information Security and Quality Assurance
|
@ -0,0 +1,7 @@
|
||||
---
|
||||
title: JavaScript Algorithms and Data Structures
|
||||
superBlock: JavaScript Algorithms and Data Structures
|
||||
---
|
||||
## Introduction to JavaScript Algorithms and Data Structures
|
||||
|
||||
This is a stub introduction for JavaScript Algorithms and Data Structures
|
@ -0,0 +1,7 @@
|
||||
---
|
||||
title: Responsive Web Design
|
||||
superBlock: Responsive Web Design
|
||||
---
|
||||
## Introduction to Responsive Web Design
|
||||
|
||||
This is a stub introduction for Responsive Web Design
|
48
packages/learn/src/templates/Introduction/SuperBlockIntro.js
Normal file
48
packages/learn/src/templates/Introduction/SuperBlockIntro.js
Normal file
@ -0,0 +1,48 @@
|
||||
/* global graphql */
|
||||
import React, { Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import Helmet from 'react-helmet';
|
||||
|
||||
import FullWidthRow from '../../components/util/FullWidthRow';
|
||||
import { MarkdownRemark } from '../../redux/propTypes';
|
||||
|
||||
const propTypes = {
|
||||
data: PropTypes.shape({
|
||||
markdownRemark: MarkdownRemark
|
||||
})
|
||||
};
|
||||
|
||||
function SuperBlockIntroductionPage(
|
||||
{ data: { markdownRemark } }
|
||||
) {
|
||||
const { html, frontmatter: { superBlock } } = markdownRemark;
|
||||
return (
|
||||
<Fragment>
|
||||
<Helmet>
|
||||
<title>{superBlock} | freeCodeCamp</title>
|
||||
</Helmet>
|
||||
<FullWidthRow>
|
||||
<div
|
||||
className='intro-layout'
|
||||
dangerouslySetInnerHTML={{ __html: html }}
|
||||
/>
|
||||
</FullWidthRow>
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
SuperBlockIntroductionPage.displayName = 'SuperBlockIntroductionPage';
|
||||
SuperBlockIntroductionPage.propTypes = propTypes;
|
||||
|
||||
export default SuperBlockIntroductionPage;
|
||||
|
||||
export const query = graphql`
|
||||
query SuperBlockIntroPageBySlug($slug: String!) {
|
||||
markdownRemark(fields: { slug: { eq: $slug } }) {
|
||||
frontmatter {
|
||||
superBlock
|
||||
}
|
||||
html
|
||||
}
|
||||
}
|
||||
`;
|
@ -20,6 +20,10 @@ const intro = path.resolve(
|
||||
__dirname,
|
||||
'../../src/templates/Introduction/Intro.js'
|
||||
);
|
||||
const superBlockIntro = path.resolve(
|
||||
__dirname,
|
||||
'../../src/templates/Introduction/SuperBlockIntro.js'
|
||||
);
|
||||
|
||||
const views = {
|
||||
backend,
|
||||
@ -73,13 +77,27 @@ exports.createChallengePages = createPage => ({ node }, index, thisArray) => {
|
||||
};
|
||||
|
||||
exports.createIntroPages = createPage => edge => {
|
||||
const { fields: { slug }, frontmatter: { block } } = edge.node;
|
||||
createPage({
|
||||
path: slug,
|
||||
component: intro,
|
||||
context: {
|
||||
block: dasherize(block),
|
||||
slug
|
||||
}
|
||||
});
|
||||
const { fields: { slug }, frontmatter: { superBlock, block } } = edge.node;
|
||||
|
||||
// If there is no block specified in the markdown we assume the markdown is
|
||||
// for a superblock introduction. Otherwise create a block intro page.
|
||||
if (!block) {
|
||||
createPage({
|
||||
path: slug,
|
||||
component: superBlockIntro,
|
||||
context: {
|
||||
superBlock: dasherize(superBlock),
|
||||
slug
|
||||
}
|
||||
});
|
||||
} else {
|
||||
createPage({
|
||||
path: slug,
|
||||
component: intro,
|
||||
context: {
|
||||
block: dasherize(block),
|
||||
slug
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user