-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: App router migration for Next.js 13 (#111)
* feat: migrate Homepage to app router * feat: migrate /maintain to app router * feat: migrate 404 page to app router * feat: migrate /about to app router * feat: migrate error page to app router * style: rename files to align the naming convention * feat: migrate notion article list page to app router * feat: migrate notion article detail page to app router * style: rename namespace to fit the new page types * refactor: remove unused redux slices and page types * feat: migrate /api/sitemap to app router * refactor: remove unused page routers * fix: use next.js notFound instead of throwing Error * fix: fix page metadata title * fix: return 404 for external notion uuid * chore: only log 1 dumpaccess once * test: fix broken meta tag e2e testing * test: increase testing timeout * fix: fix broken build
- Loading branch information
Showing
46 changed files
with
870 additions
and
1,617 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import NotionArticleDetailPage from '../../notion/article-detail-page' | ||
import { getNotionContent } from '../../notion/content' | ||
import { PAGE_TYPE_NOTION_ARTICLE_DETAIL_PAGE } from '../../../libs/constant' | ||
import { getPageMeta } from '../../../libs/util' | ||
import { getPageProperty } from '../../../libs/notion' | ||
import log from '../../../libs/server/log' | ||
|
||
export async function generateMetadata({ params, searchParams }) { | ||
const { pageName, pageSlug } = params | ||
|
||
// hack way to get fetched article property. | ||
// TODO: need to find a way to pass property instead of redundant request. | ||
const { pageContent, pageId } = await getNotionContent({ | ||
pageType: PAGE_TYPE_NOTION_ARTICLE_DETAIL_PAGE, | ||
pageName, | ||
pageSlug, | ||
searchParams, | ||
}) | ||
const property: any = getPageProperty({ pageId, recordMap: pageContent }) | ||
const metaOverride = { | ||
title: property?.PageTitle, | ||
} | ||
|
||
return getPageMeta(metaOverride, pageName) | ||
} | ||
|
||
const ArticleListPage = async ({ params, searchParams }) => { | ||
const { pageName, pageSlug } = params | ||
const { menuItems, pageContent, pageId, toc } = await getNotionContent({ | ||
pageType: PAGE_TYPE_NOTION_ARTICLE_DETAIL_PAGE, | ||
pageName, | ||
pageSlug, | ||
searchParams, | ||
}) | ||
|
||
log({ | ||
category: PAGE_TYPE_NOTION_ARTICLE_DETAIL_PAGE, | ||
message: `dumpaccess to /${pageName}/${pageSlug}`, | ||
level: 'info', | ||
}) | ||
return ( | ||
<NotionArticleDetailPage | ||
pageId={pageId} | ||
pageName={pageName} | ||
pageContent={pageContent} | ||
menuItems={menuItems} | ||
toc={toc} | ||
/> | ||
) | ||
} | ||
|
||
export default ArticleListPage |
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,33 @@ | ||
import NotionArticleListPage from '../notion/article-list-page' | ||
import { getNotionContent } from '../notion/content' | ||
import { PAGE_TYPE_NOTION_ARTICLE_LIST_PAGE } from '../../libs/constant' | ||
import { getPageMeta } from '../../libs/util' | ||
import log from '../../libs/server/log' | ||
|
||
export async function generateMetadata({ params: { pageName } }) { | ||
return getPageMeta({}, pageName) | ||
} | ||
|
||
const ArticleListPage = async ({ params, searchParams }) => { | ||
const { pageName } = params | ||
const { menuItems, articleStream } = await getNotionContent({ | ||
pageType: PAGE_TYPE_NOTION_ARTICLE_LIST_PAGE, | ||
pageName, | ||
searchParams, | ||
}) | ||
|
||
log({ | ||
category: PAGE_TYPE_NOTION_ARTICLE_LIST_PAGE, | ||
message: `dumpaccess to /${pageName}`, | ||
level: 'info', | ||
}) | ||
return ( | ||
<NotionArticleListPage | ||
pageName={pageName} | ||
menuItems={menuItems} | ||
articleStream={articleStream} | ||
/> | ||
) | ||
} | ||
|
||
export default ArticleListPage |
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,28 @@ | ||
import { getPageMeta } from '../../libs/util' | ||
import NotionSinglePage from '../notion/single-page' | ||
import { getNotionContent } from '../notion/content' | ||
import { PAGE_TYPE_NOTION_SINGLE_PAGE } from '../../libs/constant' | ||
import log from '../../libs/server/log' | ||
|
||
const pageName = 'about' | ||
|
||
export async function generateMetadata() { | ||
return getPageMeta({}, pageName) | ||
} | ||
|
||
const AboutPage = async ({ searchParams }) => { | ||
const { pageContent } = await getNotionContent({ | ||
pageType: PAGE_TYPE_NOTION_SINGLE_PAGE, | ||
pageName, | ||
searchParams, | ||
}) | ||
|
||
log({ | ||
category: PAGE_TYPE_NOTION_SINGLE_PAGE, | ||
message: `dumpaccess to /${pageName}`, | ||
level: 'info', | ||
}) | ||
return <NotionSinglePage pageName="about" pageContent={pageContent} /> | ||
} | ||
|
||
export default AboutPage |
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,37 @@ | ||
'use client' | ||
|
||
import { usePathname } from 'next/navigation' | ||
import Header from '../components/header' | ||
import Footer from '../components/footer' | ||
import { | ||
useCodeSyntaxHighlight, | ||
useResizeHandler, | ||
useInitLogRocket, | ||
} from '../libs/client/hooks' | ||
import wrapper from '../libs/client/store' | ||
|
||
// TODO: new progress bar while route change | ||
|
||
const App = ({ | ||
// Layouts must accept a children prop. | ||
// This will be populated with nested layouts or pages | ||
children, | ||
}: { | ||
children: React.ReactNode | ||
}) => { | ||
useInitLogRocket() | ||
useResizeHandler() | ||
useCodeSyntaxHighlight() | ||
|
||
const pathname = usePathname() | ||
|
||
return ( | ||
<div id="app"> | ||
<Header pathname={pathname || '/'} /> | ||
<div id="main-content">{children}</div> | ||
<Footer /> | ||
</div> | ||
) | ||
} | ||
|
||
export default wrapper.withRedux(App) |
Oops, something went wrong.