11import React from 'react'
2- import { Box , Octicon } from '@primer/react'
2+ import { Box , Octicon , Avatar , Text , Tooltip } from '@primer/react'
33import { PencilIcon } from '@primer/octicons-react'
44import Link from './link'
5- import Contributors from './contributors'
65import usePage from '../hooks/use-page'
76
8- function PageFooter ( ) {
7+ const months = [
8+ 'January' ,
9+ 'February' ,
10+ 'March' ,
11+ 'April' ,
12+ 'May' ,
13+ 'June' ,
14+ 'July' ,
15+ 'August' ,
16+ 'September' ,
17+ 'October' ,
18+ 'November' ,
19+ 'December' ,
20+ ]
21+
22+ const format = d => `${ months [ d . getMonth ( ) ] } ${ d . getDate ( ) } , ${ d . getFullYear ( ) } `
23+
24+ const pluralize = ( word , count ) => `${ word } ${ count === 1 ? '' : 's' } `
25+
26+ const Contributors = ( { contributors = [ ] , latestCommit} ) => {
27+ if ( ! contributors . length ) {
28+ return null
29+ }
30+
31+ return (
32+ < div >
33+ < Box sx = { { display : 'flex' , alignItems : 'center' } } >
34+ < Text sx = { { mr : 2 } } >
35+ { contributors . length } { pluralize ( 'contributor' , contributors . length ) }
36+ </ Text >
37+ { contributors . map ( login => (
38+ < Tooltip key = { login } aria-label = { login } >
39+ < Link href = { `https://github.com/${ login } ` } sx = { { lineHeight : 'condensedUltra' , mr : 2 } } >
40+ < Avatar src = { `https://github.com/${ login } .png?size=40` } alt = { login } />
41+ </ Link >
42+ </ Tooltip >
43+ ) ) }
44+ </ Box >
45+ { latestCommit ? (
46+ < Text sx = { { fontSize : 1 , color : 'fg.muted' , mt : 1 } } >
47+ Last edited by < Link href = { `https://github.com/${ latestCommit . login } ` } > { latestCommit . login } </ Link > on{ ' ' }
48+ < Link href = { latestCommit . url } > { format ( new Date ( latestCommit . date ) ) } </ Link >
49+ </ Text >
50+ ) : null }
51+ </ div >
52+ )
53+ }
54+
55+ const PageFooter = ( ) => {
956 const { editUrl, latestCommit, contributors = [ ] } = usePage ( ) . pageContext
10- return editUrl || contributors . length ? (
57+
58+ if ( ! editUrl && ! contributors . length ) {
59+ return null
60+ }
61+
62+ return (
1163 < Box
1264 sx = { {
1365 borderWidth : 0 ,
@@ -26,10 +78,10 @@ function PageFooter() {
2678 Edit this page on GitHub
2779 </ Link >
2880 ) : null }
29- { contributors . length ? < Contributors contributors = { contributors } latestCommit = { latestCommit } /> : null }
81+ < Contributors contributors = { contributors } latestCommit = { latestCommit } />
3082 </ Box >
3183 </ Box >
32- ) : null
84+ )
3385}
3486
3587export default PageFooter
0 commit comments