fix: remove medium links and rss feeds

This commit is contained in:
Mrugesh Mohapatra 2019-06-15 23:45:30 +05:30 committed by mrugesh
parent 1d4ae06541
commit 0ffca02ec1
6 changed files with 7 additions and 51 deletions

View File

@ -2,7 +2,6 @@ import _ from 'lodash';
import compareDesc from 'date-fns/compare_desc';
import debug from 'debug';
import { getMediumFeed } from './medium';
import { getLybsynFeed } from './lybsyn';
const log = debug('fcc:rss:news-feed');
@ -13,7 +12,6 @@ class NewsFeed {
constructor() {
this.state = {
readyState: false,
mediumFeed: [],
lybsynFeed: [],
combinedFeed: []
};
@ -31,18 +29,17 @@ class NewsFeed {
refreshFeeds = () => {
const currentFeed = this.state.combinedFeed.slice(0);
log('grabbing feeds');
return Promise.all([getMediumFeed(), getLybsynFeed()])
.then(([mediumFeed, lybsynFeed]) =>
return Promise.all([getLybsynFeed()])
.then(([lybsynFeed]) =>
this.setState(state => ({
...state,
mediumFeed,
lybsynFeed
}))
)
.then(() => {
log('crossing the streams');
const { mediumFeed, lybsynFeed } = this.state;
const combinedFeed = [...mediumFeed, ...lybsynFeed].sort((a, b) => {
const { lybsynFeed } = this.state;
const combinedFeed = [...lybsynFeed].sort((a, b) => {
return compareDesc(a.isoDate, b.isoDate);
});
this.setState(state => ({

View File

@ -1,36 +0,0 @@
import Parser from 'rss-parser';
import _ from 'lodash';
const parser = new Parser();
const mediumFeed = 'https://medium.freecodecamp.org/feed';
function getExtract(str) {
return str.slice(0, str.indexOf('</p>') + 4);
}
function addResponsiveClass(str) {
return str.replace(/<img/g, '<img class="img-responsive"');
}
export function getMediumFeed() {
return new Promise((resolve, reject) => {
parser.parseURL(mediumFeed, (err, feed) => {
if (err) {
reject(err);
}
const items = feed.items
.map(item =>
_.pick(item, ['title', 'link', 'isoDate', 'content:encoded'])
)
.map(item => ({
...item,
extract: getExtract(item['content:encoded'])
}))
.map(item => _.omit(item, ['content:encoded']))
.map(item => ({ ...item, extract: addResponsiveClass(item.extract) }));
resolve(items);
});
});
}

View File

@ -80,7 +80,6 @@ function Footer() {
<Link to='https://www.youtube.com/freecodecamp'>Youtube</Link>
<Link to='https://podcast.freecodecamp.org'>Podcast</Link>
<Link to='https://twitter.com/freecodecamp'>Twitter</Link>
<Link to='https://medium.freecodecamp.org'>Medium</Link>
<Link to='https://instagram.com/freecodecamp'>Instagram</Link>
</Col>
</Row>

View File

@ -52,11 +52,7 @@ const AboutPage = () => {
<h4>How big is the freeCodeCamp community?</h4>
<p>
If you add up all the people who use our learning platform, read
our{' '}
<Link to='https://medium.freecodecamp.org'>
Medium publication
</Link>
, watch our{' '}
our <Link to='/news'>news articles</Link>, watch our{' '}
<Link to='https://youtube.com/freecodecamp'>YouTube channel</Link>
, and post on{' '}
<Link external={true} to='/forum'>

View File

@ -42,7 +42,7 @@ exports[`createRedirects matches the snapshot 1`] = `
/forum/* https://forum.example.com/:splat 200
/privacy https://forum.example.com/t/free-code-camp-privacy-policy/19545 301
/nonprofit-project-instructions https://forum.example.com/t/how-free-code-camps-nonprofits-projects-work/19547 301
/how-nonprofit-projects-work https://medium.freecodecamp.org/open-source-for-good-1a0ea9f32d5a 301
/how-nonprofit-projects-work https://www.freecodecamp.org/news/open-source-for-good-1a0ea9f32d5a 301
"
`;

View File

@ -63,7 +63,7 @@ const template = `#api redirect
/forum/* #{{FORUM}}/:splat 200
/privacy #{{FORUM}}/t/free-code-camp-privacy-policy/19545 301
/nonprofit-project-instructions #{{FORUM}}/t/how-free-code-camps-nonprofits-projects-work/19547 301
/how-nonprofit-projects-work https://medium.freecodecamp.org/open-source-for-good-1a0ea9f32d5a 301
/how-nonprofit-projects-work https://www.freecodecamp.org/news/open-source-for-good-1a0ea9f32d5a 301
`;
/* eslint-enable max-len */