@@ -8,9 +8,12 @@ import HeaderContent from './HeaderContent';
88import Page404 from './404' ;
99import Footer from './Footer' ;
1010
11+ import contributorMap from '../utils/contributorMap' ;
12+
1113class Content extends Component {
1214 state = {
1315 data : '' ,
16+ contributor : '' ,
1417 redirect : false
1518 }
1619
@@ -27,15 +30,17 @@ class Content extends Component {
2730 getData = async ( id ) => {
2831 try {
2932 const { data } = await axios ( `https://raw.githubusercontent.com/devsonket/devsonket.github.io/develop/data/${ id } .json` ) ;
30- this . setState ( { data} ) ;
33+ let { data : contributor } = await axios ( `https://api.github.com/repos/devsonket/devsonket.github.io/commits?path=data/${ id } .json` ) ;
34+ contributor = contributorMap ( contributor ) ;
35+ this . setState ( { data, contributor} ) ;
3136 this . setTitle ( ) ;
3237 } catch ( e ) {
3338 this . setState ( { redirect : true } )
3439 }
3540 }
3641
3742 render ( ) {
38- const { data, redirect } = this . state ;
43+ const { data, contributor , redirect } = this . state ;
3944 const { match : { url } } = this . props ;
4045
4146 if ( redirect && url !== '/404' ) {
@@ -54,7 +59,7 @@ class Content extends Component {
5459
5560 return (
5661 < React . Fragment >
57- < HeaderContent title = { data . title } description = { data . description } />
62+ < HeaderContent title = { data . title } description = { data . description } contributor = { contributor } />
5863 < Container >
5964 < div className = "single-content" >
6065 { data . contents . map ( ( { title, items, code : onlyCode } , index ) => (
0 commit comments