generated from theodorusclarence/ts-nextjs-tailwind-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
984e802
commit 7b72869
Showing
7 changed files
with
149 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { | ||
GetStaticPaths, | ||
GetStaticPropsContext, | ||
InferGetStaticPropsType, | ||
} from 'next'; | ||
import * as React from 'react'; | ||
|
||
import { getAllLinkCategories, getCategoryUrls } from '@/lib/notion'; | ||
|
||
import Accent from '@/components/Accent'; | ||
import { getFaviconUrl } from '@/components/Favicon'; | ||
import Layout from '@/components/layout/Layout'; | ||
import PrimaryLink from '@/components/links/PrimaryLink'; | ||
import TreeLink from '@/components/links/TreeLink'; | ||
import Seo from '@/components/Seo'; | ||
|
||
export default function CPage({ | ||
links, | ||
category, | ||
}: InferGetStaticPropsType<typeof getStaticProps>) { | ||
return ( | ||
<Layout> | ||
<Seo templateTitle={category} /> | ||
|
||
<main> | ||
<section className=''> | ||
<div className='layout flex min-h-screen flex-col items-center justify-center py-20'> | ||
<h1 className='text-center text-5xl md:text-7xl'> | ||
<Accent>{category}</Accent> | ||
</h1> | ||
<div className='mx-auto mt-8 grid w-full max-w-sm gap-4 text-center'> | ||
{links.map((link) => ( | ||
<TreeLink | ||
key={link.pageId} | ||
link={{ | ||
display: link.slug, | ||
link: link.link!, | ||
icon: { | ||
type: 'external', | ||
external: { url: getFaviconUrl(link.link!).url }, | ||
}, | ||
}} | ||
/> | ||
))} | ||
</div> | ||
{/* Thank you for not removing this as an attribution 🙏 */} | ||
<p className='mt-10 dark:text-gray-300'> | ||
Built using{' '} | ||
<PrimaryLink href='https://github.com/theodorusclarence/notiolink'> | ||
<Accent>Notiolink</Accent> | ||
</PrimaryLink> | ||
</p> | ||
</div> | ||
</section> | ||
</main> | ||
</Layout> | ||
); | ||
} | ||
|
||
export const getStaticPaths: GetStaticPaths = async () => { | ||
const categories = await getAllLinkCategories(); | ||
|
||
return { | ||
paths: categories.map((category) => ({ params: { category } })), | ||
fallback: false, | ||
}; | ||
}; | ||
|
||
export const getStaticProps = async (context: GetStaticPropsContext) => { | ||
const category = context.params?.category as string; | ||
return { | ||
props: { links: await getCategoryUrls(category), category }, | ||
revalidate: 5, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7b72869
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: