summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2021-12-24 15:13:19 +0100
committerArmand Philippot <git@armandphilippot.com>2021-12-24 15:13:19 +0100
commit3956ed77e11455a963ce17a64783d70fa666a7a0 (patch)
tree15eadb57f8f68fd7a5c56fc2b7cdeb17d21b7ab2
parent8105e2577d4aa401f960e78085f6038eb879ee8a (diff)
chore: replace homepage content with MDX content
I cannot import custom blocks through WP GraphQL, so I prefer to use MDX file. This way I cannot import custom components.
-rw-r--r--src/pages/index.tsx10
-rw-r--r--src/services/graphql/queries.ts19
-rw-r--r--src/ts/types/app.ts2
-rw-r--r--src/ts/types/homepage.ts12
4 files changed, 3 insertions, 40 deletions
diff --git a/src/pages/index.tsx b/src/pages/index.tsx
index 4146f34..3d4f6ff 100644
--- a/src/pages/index.tsx
+++ b/src/pages/index.tsx
@@ -4,18 +4,17 @@ import Head from 'next/head';
import Layout from '@components/Layouts/Layout';
import { seo } from '@config/seo';
import { NextPageWithLayout } from '@ts/types/app';
-import { HomePage, HomePageProps } from '@ts/types/homepage';
import { loadTranslation } from '@utils/helpers/i18n';
-import { getHomePage } from '@services/graphql/queries';
+import HomePageContent from '@content/pages/homepage.mdx';
-const Home: NextPageWithLayout<HomePageProps> = ({ data }) => {
+const Home: NextPageWithLayout = () => {
return (
<>
<Head>
<title>{seo.homepage.title}</title>
<meta name="description" content={seo.homepage.description} />
</Head>
- <div dangerouslySetInnerHTML={{ __html: data.content }}></div>
+ <HomePageContent />
</>
);
};
@@ -30,11 +29,8 @@ export const getStaticProps: GetStaticProps = async (ctx) => {
process.env.NODE_ENV === 'production'
);
- const data: HomePage = await getHomePage();
-
return {
props: {
- data,
translation,
},
};
diff --git a/src/services/graphql/queries.ts b/src/services/graphql/queries.ts
index 652caa1..518cf75 100644
--- a/src/services/graphql/queries.ts
+++ b/src/services/graphql/queries.ts
@@ -1,7 +1,6 @@
import { Slug } from '@ts/types/app';
import { Article, PostBy } from '@ts/types/articles';
import { AllPostsSlug, PostsList, RawPostsList } from '@ts/types/blog';
-import { HomePage, HomePageBy } from '@ts/types/homepage';
import { Page, PageBy } from '@ts/types/pages';
import {
AllSubjectsSlug,
@@ -238,24 +237,6 @@ export const getPostBySlug = async (slug: string): Promise<Article> => {
// Pages query
//==============================================================================
-export const getHomePage = async (): Promise<HomePage> => {
- const query = gql`
- query HomePage {
- nodeByUri(uri: "/") {
- ... on Page {
- id
- content
- }
- }
- }
- `;
-
- const response = await fetchApi<HomePageBy>(query, null);
- const homepage = response.nodeByUri;
-
- return homepage;
-};
-
export const getPageByUri = async (slug: string): Promise<Page> => {
const query = gql`
query PageByUri($slug: String!) {
diff --git a/src/ts/types/app.ts b/src/ts/types/app.ts
index a8c552d..ebd604c 100644
--- a/src/ts/types/app.ts
+++ b/src/ts/types/app.ts
@@ -5,7 +5,6 @@ import { PostBy } from './articles';
import { AllPostsSlug, RawPostsList } from './blog';
import { CommentData, CreateComment } from './comments';
import { ContactData, SendEmail } from './contact';
-import { HomePageBy } from './homepage';
import { PageBy } from './pages';
import {
AllSubjectsSlug,
@@ -49,7 +48,6 @@ export type RequestType =
| AllSubjectsSlug
| AllThematicsSlug
| CreateComment
- | HomePageBy
| PageBy
| PostBy
| SubjectBy
diff --git a/src/ts/types/homepage.ts b/src/ts/types/homepage.ts
deleted file mode 100644
index 8ff2ccb..0000000
--- a/src/ts/types/homepage.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-export type HomePage = {
- id: string;
- content: string;
-};
-
-export type HomePageBy = {
- nodeByUri: HomePage;
-};
-
-export type HomePageProps = {
- data: HomePage;
-};