-
Notifications
You must be signed in to change notification settings - Fork 115
Expand file tree
/
Copy pathtutorials.js
More file actions
43 lines (38 loc) · 996 Bytes
/
tutorials.js
File metadata and controls
43 lines (38 loc) · 996 Bytes
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
36
37
38
39
40
41
42
43
import { useMemo } from 'react';
import { useIntl } from 'react-intl';
/**
Hook to prepare the video and text examples
**/
export const usePreparedTutorials = (tutorials) => {
return useMemo(() => {
let prepared = [];
for (let i = 0; i < tutorials.length; i++) {
const { coverImage, ...rest } = tutorials[i].childMdx.frontmatter;
prepared.push({
...rest,
image: coverImage.childImageSharp.gatsbyImageData
});
}
return prepared;
}, [tutorials]);
};
/**
Hook to prepare the trail used for the breadcumbs
Example: Learn > Tutorials > Text Tutorials
**/
export const useTrail = () => {
const intl = useIntl();
return useMemo(() => {
return [
intl.formatMessage({ id: 'learn' }),
{
slug: '/tutorials',
label: intl.formatMessage({ id: 'tutorials' })
},
{
slug: '/tutorials#text-tutorials',
label: intl.formatMessage({ id: 'textTutorials' })
}
];
}, [intl]);
};