Files
freeCodeCamp/client/utils/gatsby/guidePageCreator.js
jnguyen0220 414219965d fix: adding f to the featureImage source (#35758)
<!-- Please follow this checklist and put an x in each of the boxes, like this: [x]. It will ensure that our team takes your pull request seriously. -->

- [x] I have read [freeCodeCamp's contribution guidelines](https://github.com/freeCodeCamp/freeCodeCamp/blob/master/CONTRIBUTING.md).
- [x] My pull request has a descriptive title (not a vague title like `Update index.md`)
- [x] My pull request targets the `master` branch of freeCodeCamp.
- [x] None of my changes are plagiarized from another source without proper attribution.
- [x] All the files I changed are in the same world language (for example: only English changes, or only Chinese changes, etc.)
- [x] My changes do not use shortened URLs or affiliate links.

<!--If your pull request closes a GitHub issue, replace the XXXXX below with the issue number.-->

Closes #35749
2019-04-04 10:54:31 +05:30

48 lines
1.1 KiB
JavaScript

const path = require('path');
const select = require('unist-util-select');
const { head } = require('lodash');
const { isAStubRE } = require('../regEx');
const guideArticle = path.resolve(
__dirname,
'../../src/templates/Guide/GuideArticle.js'
);
exports.createGuideArticlePages = createPage => ({
node: {
htmlAst,
excerpt,
fields: { slug, component },
id
}
}) => {
let meta = {};
if (!isAStubRE.test(excerpt)) {
const featureImage = head(select(htmlAst, 'element[tagName=img]'));
meta.featureImage = featureImage
? featureImage.properties.src
: 'https://s3.amazonaws.com/freecodecamp' +
'/freecodecamp-square-logo-large.jpg';
const description = head(select(htmlAst, 'element[tagName=p]'));
meta.description = description ? description.children[0].value : '';
}
return createPage({
path: `/guide${slug}`,
component: !component
? guideArticle
: path.resolve(
__dirname,
'../../src/templates/Guide/components/',
component
),
context: {
id,
meta
}
});
};