@@ -3,9 +3,11 @@ import { css, keyframes } from '@emotion/react'
33import { Fragment } from 'react'
44import { graphql , useStaticQuery } from 'gatsby'
55import { IndexBannerQuery } from '@teimurjan/gql-types'
6+ import Resume , { PDFDownloadLink } from '@teimurjan/resume'
67import { theme } from '@teimurjan/utils'
78import { Banner } from '../../molecules'
89import { Button , Square } from '../../atoms'
10+ import { useLazyInitialization } from '../../../hooks'
911
1012const roll = ( rotation : number ) => keyframes `
1113 0% {
@@ -24,17 +26,62 @@ const query = graphql`
2426 fullName
2527 headline
2628 about
29+ location
30+ phoneNumber
31+ email
32+ }
33+ educations(or derBy: startDate_DESC) {
34+ id
35+ school
36+ degree
37+ areaOfStudy
38+ startDate
39+ endDate
40+ }
41+ skills(or derBy: yearsOfExperience_DESC) {
42+ id
43+ title
44+ yearsOfExperience
45+ }
46+ experiences(or derBy: startDate_DESC) {
47+ id
48+ company
49+ position
50+ startDate
51+ endDate
52+ description {
53+ html
54+ }
55+ }
56+ publications {
57+ id
58+ title
59+ link
60+ date
61+ }
62+ conferences {
63+ id
64+ title
65+ to pic
66+ link
67+ date
2768 }
2869 }
2970 }
3071`
3172
3273const IndexBanner = ( ) => {
74+ const data = useStaticQuery < IndexBannerQuery > ( query )
3375 const {
3476 gcms : {
3577 bios : [ { fullName, headline, about } ] ,
3678 } ,
37- } = useStaticQuery < IndexBannerQuery > ( query )
79+ } = data
80+ const { value : shouldGeneratePDFInBrowser , isInitialized } =
81+ useLazyInitialization (
82+ process . env . NODE_ENV === 'development' && typeof window !== 'undefined' ,
83+ false
84+ )
3885
3986 return (
4087 < Banner
@@ -45,9 +92,33 @@ const IndexBanner = () => {
4592 subtitle = { headline }
4693 description = { about }
4794 button = {
48- < Button . Link type = "external" to = "/resume.pdf" >
49- Get resume
50- </ Button . Link >
95+ shouldGeneratePDFInBrowser && isInitialized ? (
96+ < PDFDownloadLink
97+ document = { < Resume { ...data } /> }
98+ fileName = "resume.pdf"
99+ >
100+ { ( { url, loading } ) => (
101+ < Button
102+ onClick = { ( e ) => {
103+ // Prevent download action to be triggered
104+ e . stopPropagation ( )
105+ e . preventDefault ( )
106+
107+ if ( url ) {
108+ window . open ( url , '_blank' )
109+ }
110+ } }
111+ disabled = { loading }
112+ >
113+ Get resume
114+ </ Button >
115+ ) }
116+ </ PDFDownloadLink >
117+ ) : (
118+ < Button . Link type = "external" to = "/resume.pdf" >
119+ Get resume
120+ </ Button . Link >
121+ )
51122 }
52123 image = {
53124 < Fragment >
0 commit comments