summaryrefslogtreecommitdiffstats
path: root/src/services/graphql/pages.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/services/graphql/pages.ts')
-rw-r--r--src/services/graphql/pages.ts60
1 files changed, 0 insertions, 60 deletions
diff --git a/src/services/graphql/pages.ts b/src/services/graphql/pages.ts
deleted file mode 100644
index 0781d44..0000000
--- a/src/services/graphql/pages.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-import {
- FetchPageByUriReturn,
- GetPageReturn,
- 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);
- }
-};
-
-const getFormattedPage = (page: RawPage) => {
- const formattedPage: Page = {
- ...page,
- content: page.contentParts.afterMore,
- intro: page.contentParts.beforeMore,
- };
-
- return formattedPage;
-};
-
-export const getCVPage: GetPageReturn = async () => {
- const rawCV = await fetchPageByUri('/cv/');
- const formattedCV = getFormattedPage(rawCV);
-
- return formattedCV;
-};
-
-export const getLegalNoticePage: GetPageReturn = async () => {
- const rawLegalNotice = await fetchPageByUri('/mentions-legales');
- const formattedLegalNotice = getFormattedPage(rawLegalNotice);
-
- return formattedLegalNotice;
-};