Skip to content

Commit 73b6a9d

Browse files
committed
add sponsors
1 parent 15ce571 commit 73b6a9d

9 files changed

Lines changed: 494 additions & 9 deletions

File tree

‎frontend/main/src/components/PurrfectDevUpper.tsx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Link from 'next/link';
22
import AJHeadphones from '@/components/global/icons/AJHeadphones';
3+
import AJHeartsLeft from './global/icons/AJHeart';
34

45
export default function PurrfectDevUpper(): JSX.Element {
56
return (
@@ -47,6 +48,11 @@ export default function PurrfectDevUpper(): JSX.Element {
4748
</button>
4849
</a>
4950
</Link>
51+
<Link href="/sponsors">
52+
<a className="flex items-center justify-center text-2xl underline">
53+
See Our Sponsors <AJHeartsLeft />
54+
</a>
55+
</Link>
5056
</div>
5157
</section>
5258
<section className="grid grid-cols-1 row-start-1 -ml-10 lg:col-start-2 place-items-center 3xl:justify-items-start 3xl:ml-0">

‎frontend/main/src/config/notion.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export const config = {
44
purrfectGuestDb: process.env.NOTION_PURRFECT_GUEST || '',
55
purrfectCompanyDb: process.env.NOTION_PURRFECT_COMPANY || '',
66
purrfectPicksDb: process.env.NOTION_PURRFECT_PICKS || '',
7+
purrfectSponsorsDb: process.env.NOTION_PURRFECT_SPONSORS || '',
78
postsDb: process.env.NOTION_POSTS || '',
89
tutorialsDb: process.env.NOTION_TUTORIALS || '',
910
pagesDb: process.env.NOTION_PAGES || '',

‎frontend/main/src/models/sponsor.model.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { CoverMedia } from './post.model';
33
export interface Sponsor {
44
//Auto Generated By Cloud Function
55
_id: string;
6+
id: string;
67
createdAt?: Timestamp;
78
updatedAt?: Timestamp;
89
createdBy?: string;

‎frontend/main/src/pages/authors/index.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const Podcasts = ({
4646
<Authors authors={posts as unknown as Author[]} />
4747
<Pagination
4848
posts={posts}
49-
baseUrl="blog"
49+
baseUrl="author"
5050
pageNumber={1}
5151
showNext={showNext}
5252
/>
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
import {
2+
getSite,
3+
queryByPublished,
4+
queryRelationById,
5+
getSponsorPageBlocks,
6+
} from '@/services/notion.server';
7+
import { NextSeo } from 'next-seo';
8+
import Layout from '@/layout/Layout';
9+
import { Site } from '@/models/site.model';
10+
import { Post, PostType } from '@/models/post.model';
11+
import PostsCards from '@/components/PostsCards';
12+
import { GetStaticPaths, GetStaticProps, InferGetStaticPropsType } from 'next';
13+
import { Sponsor } from '@/models/sponsor.model';
14+
import Image from 'next/image';
15+
16+
interface StaticParams {
17+
site: Site;
18+
sponsor: Sponsor;
19+
podcasts: Post[];
20+
}
21+
22+
export const getStaticPaths: GetStaticPaths = async () => {
23+
const paths: { params: { sponsorPath: string } }[] = [];
24+
const sponsors = await queryByPublished('sponsor', 10000);
25+
console.log('sponsors', sponsors);
26+
for (const p of sponsors.results as any) {
27+
if (p?.properties?.slug?.url) {
28+
paths.push({
29+
params: {
30+
sponsorPath: `${p?.properties?.slug?.url}`,
31+
},
32+
});
33+
}
34+
}
35+
return {
36+
paths,
37+
fallback: true,
38+
};
39+
};
40+
41+
export const getStaticProps: GetStaticProps<StaticParams> = async ({
42+
params,
43+
preview,
44+
previewData,
45+
}) => {
46+
const { sponsorPath } = params as any;
47+
48+
if (!sponsorPath) {
49+
return {
50+
notFound: true,
51+
};
52+
}
53+
const site = getSite();
54+
const sponsor = await getSponsorPageBlocks(sponsorPath);
55+
56+
if (!sponsor) {
57+
console.log('Sponsor not found');
58+
return {
59+
notFound: true,
60+
};
61+
}
62+
63+
const [podcasts] = await Promise.all([
64+
queryRelationById(sponsor.id, 'sponsors', PostType.podcast),
65+
]);
66+
67+
return {
68+
props: {
69+
site,
70+
sponsor,
71+
podcasts: podcasts?.results || null,
72+
},
73+
};
74+
};
75+
76+
export default function SponsorPage({
77+
site,
78+
sponsor,
79+
podcasts,
80+
}: InferGetStaticPropsType<typeof getStaticProps>) {
81+
return (
82+
<>
83+
<NextSeo
84+
title={`${sponsor?.company || ''} | CodingCatDev`}
85+
canonical={`https://codingcat.dev/sponsors/`}
86+
></NextSeo>
87+
<Layout site={site}>
88+
<section className="grid grid-cols-1 gap-20 p-4 sm:p-10 place-items-center">
89+
<a href={sponsor.url} rel="noreferrer noopener" target="_blank">
90+
<article className="grid items-start grid-cols-1 gap-4 shadow-lg rounded-xl justify-items-center justify-self-center hover:shadow-sm">
91+
<div className="w-full rounded-lg shadow-lg bg-primary-100 dark:bg-primary-500">
92+
<div className="p-2">
93+
<div
94+
style={{
95+
overflow: 'hidden',
96+
paddingTop: '56.25%',
97+
position: 'relative',
98+
width: '100%',
99+
height: 0,
100+
}}
101+
>
102+
<div className="absolute inset-0 flex flex-col items-center justify-center p-2">
103+
{sponsor?.coverPhoto?.public_id && (
104+
<Image
105+
src={sponsor.coverPhoto.public_id}
106+
alt={`Sponsorship Image for ${sponsor.company}`}
107+
layout="fill"
108+
/>
109+
)}
110+
</div>
111+
</div>
112+
<h2 className="flex flex-wrap content-center pl-1 text-2xl font-semibold">
113+
{sponsor.company}
114+
</h2>
115+
<p className="m-2 text-lg">{sponsor.description}</p>
116+
</div>
117+
<div className="flex w-full mt-2 rounded-b-lg bg-primary-900">
118+
<p className="px-4 py-2 text-sm text-white uppercase border-none cursor-pointer">
119+
More Information -{'>'}
120+
</p>
121+
</div>
122+
</div>
123+
</article>
124+
</a>
125+
</section>
126+
{podcasts && podcasts.length > 0 && (
127+
<section className="grid w-full gap-10 px-4 mx-auto xl:px-10">
128+
<h2 className="mt-4 text-4xl text-primary-900 lg:text-5xl">
129+
Podcasts
130+
</h2>
131+
{podcasts && <PostsCards posts={podcasts} />}
132+
</section>
133+
)}
134+
</Layout>
135+
</>
136+
);
137+
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import { NextSeo } from 'next-seo';
2+
import Layout from '@/layout/Layout';
3+
import { Site } from '@/models/site.model';
4+
import { queryByPublished } from '@/services/notion.server';
5+
import { getSite } from '@/services/notion.server';
6+
import { GetStaticProps, InferGetStaticPropsType } from 'next';
7+
import { Pagination } from '@/components/NotionPagination';
8+
import SponsorCards from '@/components/SponsorCards';
9+
import { Sponsor } from '@/models/sponsor.model';
10+
import { Post } from '@/models/post.model';
11+
import Image from 'next/image';
12+
import Link from 'next/link';
13+
14+
interface StaticParams {
15+
site: Site;
16+
sponsors: Sponsor[];
17+
showNext: boolean;
18+
}
19+
20+
export const getStaticProps: GetStaticProps<StaticParams> = async ({
21+
preview = false,
22+
}) => {
23+
const notionPosts = await queryByPublished('sponsor', 20);
24+
25+
return {
26+
props: {
27+
site: getSite(),
28+
sponsors: notionPosts.results as unknown as Sponsor[],
29+
showNext: notionPosts.has_more,
30+
},
31+
revalidate: 3600,
32+
};
33+
};
34+
35+
const Sponsors = ({
36+
site,
37+
sponsors,
38+
showNext,
39+
}: InferGetStaticPropsType<typeof getStaticProps>) => {
40+
return (
41+
<>
42+
<NextSeo
43+
title="Sponsors | CodingCatDev"
44+
canonical={`https://codingcat.dev/sponsors/`}
45+
></NextSeo>
46+
<Layout site={site}>
47+
<section className="flex justify-center p-4">
48+
<h1 className="text-5xl lg:text-7xl">Sponsors</h1>
49+
</section>
50+
<section className="flex flex-wrap justify-center gap-10 p-4 md:grid md:grid-cols-[1fr_1fr_1fr] sm:p-10">
51+
{sponsors.map((s, i) => (
52+
<div className="w-full p-2" key={i}>
53+
<Link href={`/sponsors/${s.slug}`}>
54+
<a>
55+
<div className="w-full rounded-lg shadow-lg bg-primary-100 dark:bg-primary-500">
56+
<div className="p-2">
57+
<div
58+
style={{
59+
overflow: 'hidden',
60+
paddingTop: '56.25%',
61+
position: 'relative',
62+
width: '100%',
63+
height: 0,
64+
}}
65+
>
66+
<div className="absolute inset-0 flex flex-col items-center justify-center p-2">
67+
{s?.coverPhoto?.public_id && (
68+
<Image
69+
src={s.coverPhoto.public_id}
70+
alt={`Sponsorship Image for ${s.company}`}
71+
layout="fill"
72+
/>
73+
)}
74+
</div>
75+
</div>
76+
<h2 className="flex flex-wrap content-center pl-1 text-2xl font-semibold">
77+
{s.company}
78+
</h2>
79+
<p className="m-2 text-lg">{s.description}</p>
80+
</div>
81+
<div className="flex w-full mt-2 rounded-b-lg bg-primary-900">
82+
<p className="px-4 py-2 text-sm text-white uppercase border-none cursor-pointer">
83+
More Information -{'>'}
84+
</p>
85+
</div>
86+
</div>
87+
</a>
88+
</Link>
89+
</div>
90+
))}
91+
</section>
92+
<Pagination
93+
posts={sponsors as unknown as Post[]}
94+
baseUrl="sponsors"
95+
pageNumber={1}
96+
showNext={showNext}
97+
/>
98+
</Layout>
99+
</>
100+
);
101+
};
102+
export default Sponsors;

0 commit comments

Comments
 (0)