Skip to content

Commit 0c645e2

Browse files
committed
remove contentful dependency. step 1
1 parent ede20d2 commit 0c645e2

File tree

6 files changed

+288
-85
lines changed

6 files changed

+288
-85
lines changed

src/app/about/page.tsx

Lines changed: 6 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import {FALLBACK_LOCALE, Locales} from '@/app/i18n/settings';
2-
import {EntryFieldTypes} from 'contentful';
32
import dompurify from 'isomorphic-dompurify';
43
import type {Metadata, NextPage} from 'next';
54
import dynamicImport from 'next/dynamic';
65
import AboutMeHero from '../../components/AboutMeHero';
76
import NextLink from '../../components/basic/NextLink';
87
import {newCommonMetaTags} from '../../frontend-utils/meta-tags';
9-
import type {StaticContent} from '../../models/static-content';
10-
import {client, getBlurringImage} from '../../utils/contentful.utils';
11-
import {mapLocale} from '../i18n/map-locale.util';
8+
import {getBlurringImage} from '../../utils/contentful.utils';
9+
import {aboutMeData} from '@/models/static-content';
1210

1311
const TechStackCarousel = dynamicImport(
1412
() => import('../../components/TechStackCarousel'),
@@ -23,7 +21,7 @@ export async function generateMetadata(): Promise<Metadata> {
2321

2422
const AboutMePage: NextPage = async () => {
2523
const {
26-
props: {aboutMeDetails, img, svg, techStacks},
24+
props: {aboutMeDetails, img, svg},
2725
} = await getStaticProps();
2826
return (
2927
<>
@@ -49,24 +47,6 @@ const AboutMePage: NextPage = async () => {
4947
})}
5048
</article>
5149

52-
<h2 className="text-center">This website is powered by</h2>
53-
<TechStackCarousel techStacks={techStacks} />
54-
55-
<section className="mb-2 mt-4">
56-
<h4 className="text-center">
57-
This awesome carousel is easily made using&nbsp;
58-
<NextLink
59-
href="https://github.com/leandrowd/react-responsive-carousel"
60-
target="_blank"
61-
aria-label="React Responsive Carousel"
62-
rel="noreferrer"
63-
className="text-primary-900 dark:text-primary-300"
64-
>
65-
React Responsive Carousel
66-
</NextLink>
67-
.
68-
</h4>
69-
</section>
7050
<section className="pb-8">
7151
<h4 className="text-center">
7252
Here is the link to my&nbsp;
@@ -86,45 +66,15 @@ const AboutMePage: NextPage = async () => {
8666
);
8767
};
8868

89-
type StaticAssetSkeleton = {
90-
contentTypeId: 'staticText';
91-
fields: {
92-
key: EntryFieldTypes.Text;
93-
content: EntryFieldTypes.Text;
94-
category: EntryFieldTypes.Text;
95-
label: EntryFieldTypes.Text;
96-
order: EntryFieldTypes.Number;
97-
};
98-
};
99-
10069
const getStaticProps = async () => {
101-
const entries = await client.getEntries<StaticAssetSkeleton, Locales>({
102-
content_type: 'staticText',
103-
'fields.category': 'about_me',
104-
order: ['fields.order'],
105-
locale: mapLocale(FALLBACK_LOCALE),
106-
});
70+
// Use local about me data instead of Contentful
71+
const aboutMeDetails = aboutMeData.sort((a, b) => a.order - b.order);
10772

10873
const {img, svg} = await getBlurringImage('batman_cover.png');
10974

110-
const assets = await client.getAssets<Locales>({
111-
'fields.title[in]': [
112-
'React,TypeScript,NextJS,Prettier,ESLint,Emotion,Supabase,GitHub,Vercel',
113-
],
114-
});
115-
116-
const techStacks = assets.items.map(asset => ({
117-
...asset,
118-
name: asset.fields.title as string,
119-
url: asset.fields.file?.url as string,
120-
}));
121-
12275
return {
12376
props: {
124-
aboutMeDetails: entries.items.map(
125-
entry => entry.fields,
126-
) as StaticContent[],
127-
techStacks,
77+
aboutMeDetails,
12878
img,
12979
svg,
13080
},

src/app/novel/[slug]/page.tsx

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,23 @@ import BlogContent from '@/modules/blog/BlogContent';
77
import BlogHeader from '@/modules/blog/BlogHeader';
88
import ContentLayout from '@/modules/common/ContentLayout';
99
import {getNovelsMetadata, NOVELS_PATH} from '@/utils/mdx.utils';
10-
import {client} from '@/utils/contentful.utils';
1110
import {blurImage} from '@/utils/image-blur.utils';
1211
import BlogFooter from '@/modules/blog/BlogFooter';
1312
import {newCommonMetaTags} from '@/frontend-utils/meta-tags';
1413
import Script from 'next/script';
14+
import {getImageUrl} from '@/utils/get-image';
1515

16-
export const generateMetadata = async (
17-
props: {
18-
params: Promise<{slug: string}>;
19-
}
20-
): Promise<Metadata> => {
16+
export const generateMetadata = async (props: {
17+
params: Promise<{slug: string}>;
18+
}): Promise<Metadata> => {
2119
const params = await props.params;
2220
const postFilePath = path.join(NOVELS_PATH, `${params.slug}.mdx`);
2321
const source = fs.readFileSync(postFilePath);
2422

2523
const {data: novel} = matter(source);
2624
novel.slug = params.slug;
2725

28-
const asset = await client.getAsset(novel.bannerId);
29-
30-
const bannerUrl = `https:${asset.fields.file?.url}`;
26+
const bannerUrl = getImageUrl('codecraft.jpeg');
3127

3228
return {
3329
...newCommonMetaTags(novel.title, `/novel/${novel.slug}`),
@@ -58,9 +54,7 @@ const BlogPage: NextPage<{
5854
}> = async props => {
5955
const params = await props.params;
6056

61-
const {
62-
slug
63-
} = params;
57+
const {slug} = params;
6458

6559
const {
6660
frontMatter: novel,
@@ -120,10 +114,8 @@ const getStaticProps = async (slug: string) => {
120114
const source = fs.readFileSync(postFilePath);
121115

122116
const {content, data} = matter(source);
117+
const bannerUrl = getImageUrl('codecraft.jpeg');
123118

124-
const banner = await client.getAsset(data.bannerId);
125-
126-
const bannerUrl = `https:${banner.fields.file?.url}`;
127119
const {img, svg} = await blurImage(bannerUrl);
128120

129121
return {

src/app/novel/page.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import SubscribeForm from '@/components/SubscribeForm';
33
import {newCommonMetaTags} from '@/frontend-utils/meta-tags';
44
import type {INovelMetadata} from '@/models/mdxFiles';
55
import {getNovelsMetadata} from '@/utils/mdx.utils';
6-
import {client} from '@/utils/contentful.utils';
76
import NovelsWrapper from './NovelsWrapper';
87
import {createTranslation} from '../i18n/server';
8+
import {getImageUrl} from '@/utils/get-image';
99

1010
export const metadata = {
1111
...newCommonMetaTags('Novels Page', '/novel'),
@@ -37,10 +37,7 @@ const getStaticProps = async () => {
3737
);
3838

3939
for (let blog of novels) {
40-
const asset = await client.getAsset(blog.bannerId);
41-
42-
const bannerUrl = `https:${asset.fields.file?.url}`;
43-
blog.bannerId = bannerUrl;
40+
blog.bannerId = getImageUrl('codecraft.jpeg');
4441
}
4542

4643
return {

0 commit comments

Comments
 (0)