blob: 6689e374805a961cffaa969aa9672b437bfd210f (
plain)
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
44
45
46
47
48
|
import {
FetchPageByUriReturn,
GetCVPageReturn,
Page,
PageResponse,
RawPage,
} from '@ts/types/pages';
import { gql } from 'graphql-request';
import { getGraphQLClient } from './client';
const fetchPageByUri: FetchPageByUriReturn = async (uri: string) => {
const client = getGraphQLClient();
const query = gql`
query PageByUri($uri: String!) {
pageBy(uri: $uri) {
contentParts {
afterMore
beforeMore
}
date
modified
title
}
}
`;
const variables = { uri };
try {
const response: PageResponse = await client.request(query, variables);
return response.pageBy;
} catch (error) {
console.error(JSON.stringify(error, undefined, 2));
process.exit(1);
}
};
export const getCVPage: GetCVPageReturn = async () => {
const rawCV = await fetchPageByUri('/cv/');
const formattedCV: Page = {
...rawCV,
content: rawCV.contentParts.afterMore,
intro: rawCV.contentParts.beforeMore,
};
return formattedCV;
};
|