-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgatsby-ssr.js
35 lines (30 loc) · 914 Bytes
/
gatsby-ssr.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* Implement Gatsby's SSR (Server Side Rendering) APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/ssr-apis/
*/
// You can delete this file if you're not using it
import React from 'react'
import Player from './src/components/Player'
export const wrapPageElement = ({ element, props }) => {
// props provide same data to Layout as Page element will get
// including location, data, etc - you don't need to pass it
const {
pageContext: { allAudioFiles },
} = props
return (
<Player audioFiles={allAudioFiles}>
{({ play, pause, isPlaying, isValidAudioFileKey, selectedKey }) =>
React.cloneElement(element, {
play: play,
pause: pause,
isPlaying: isPlaying,
isValidAudioFileKey: isValidAudioFileKey,
selectedKey: selectedKey,
key: 'SSR',
isDisabled: true,
})
}
</Player>
)
}