diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/molecules/modals/tooltip/tooltip.tsx | 2 | ||||
| -rw-r--r-- | src/components/organisms/forms/search-form/search-form.tsx | 6 | ||||
| -rw-r--r-- | src/components/organisms/nav/main-nav/main-nav.tsx | 13 | ||||
| -rw-r--r-- | src/pages/_app.tsx | 1 | ||||
| -rw-r--r-- | src/pages/article/[slug].tsx | 19 | ||||
| -rw-r--r-- | src/pages/blog/page/[number].tsx | 44 |
6 files changed, 59 insertions, 26 deletions
diff --git a/src/components/molecules/modals/tooltip/tooltip.tsx b/src/components/molecules/modals/tooltip/tooltip.tsx index 525900d..87e9ac8 100644 --- a/src/components/molecules/modals/tooltip/tooltip.tsx +++ b/src/components/molecules/modals/tooltip/tooltip.tsx @@ -83,7 +83,9 @@ export const Tooltip: FC<TooltipProps> = ({ {heading} </Heading> } + // eslint-disable-next-line react/jsx-no-literals icon={<Icon aria-hidden shape="help" size="sm" />} + // eslint-disable-next-line react/jsx-no-literals kind="secondary" ref={modalRef} > diff --git a/src/components/organisms/forms/search-form/search-form.tsx b/src/components/organisms/forms/search-form/search-form.tsx index a803d8c..eb4f51d 100644 --- a/src/components/organisms/forms/search-form/search-form.tsx +++ b/src/components/organisms/forms/search-form/search-form.tsx @@ -124,7 +124,11 @@ const SearchFormWithRef: ForwardRefRenderFunction< </Button> </Form> {messages?.error && submitStatus === 'FAILED' ? ( - <Notice className={styles.notice} kind="error"> + <Notice + className={styles.notice} + // eslint-disable-next-line react/jsx-no-literals + kind="error" + > {messages.error} </Notice> ) : null} diff --git a/src/components/organisms/nav/main-nav/main-nav.tsx b/src/components/organisms/nav/main-nav/main-nav.tsx index 5a19399..57d8d6e 100644 --- a/src/components/organisms/nav/main-nav/main-nav.tsx +++ b/src/components/organisms/nav/main-nav/main-nav.tsx @@ -28,10 +28,19 @@ const MainNavWithRef: ForwardRefRenderFunction<HTMLElement, MainNavProps> = ( return ( <Nav {...props} className={wrapperClass} ref={ref}> - <NavList isInline spacing="2xs"> + <NavList + isInline + // eslint-disable-next-line react/jsx-no-literals + spacing="2xs" + > {items.map(({ id, ...link }) => ( <NavItem key={id}> - <NavLink {...link} isStack variant="main" /> + <NavLink + {...link} + isStack + // eslint-disable-next-line react/jsx-no-literals + variant="main" + /> </NavItem> ))} </NavList> diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 525335f..42b3de4 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -22,6 +22,7 @@ const App = ({ Component, pageProps }: AppPropsWithLayout) => { domainId={CONFIG.ackee.siteId} server={CONFIG.ackee.url} storageKey={STORAGE_KEY.ACKEE} + // eslint-disable-next-line react/jsx-no-literals tracking="full" > <MotionProvider diff --git a/src/pages/article/[slug].tsx b/src/pages/article/[slug].tsx index e18de75..ecff692 100644 --- a/src/pages/article/[slug].tsx +++ b/src/pages/article/[slug].tsx @@ -3,7 +3,7 @@ import type { ParsedUrlQuery } from 'querystring'; import type { GetStaticPaths, GetStaticProps } from 'next'; import Head from 'next/head'; import { useRouter } from 'next/router'; -import { useCallback } from 'react'; +import { type FC, useCallback } from 'react'; import { useIntl } from 'react-intl'; import { getLayout, @@ -60,12 +60,8 @@ type ArticlePageProps = { translation: Messages; }; -/** - * Article page. - */ -const ArticlePage: NextPageWithLayout<ArticlePageProps> = ({ data }) => { +const Article: FC<Pick<ArticlePageProps, 'data'>> = ({ data }) => { const intl = useIntl(); - const { isFallback } = useRouter(); const { article, isLoading } = useArticle(data.post.slug, data.post); const { comments, isLoading: areCommentsLoading } = useComments({ fallback: data.comments, @@ -137,7 +133,7 @@ const ArticlePage: NextPageWithLayout<ArticlePageProps> = ({ data }) => { [] ); - if (isFallback || isLoading) return <LoadingPage />; + if (isLoading) return <LoadingPage />; const { content, id, intro, meta, slug, title } = article; const { @@ -276,6 +272,15 @@ const ArticlePage: NextPageWithLayout<ArticlePageProps> = ({ data }) => { ); }; +/** + * Article page. + */ +const ArticlePage: NextPageWithLayout<ArticlePageProps> = ({ data }) => { + const { isFallback } = useRouter(); + + return isFallback ? <LoadingPage /> : <Article data={data} />; +}; + ArticlePage.getLayout = (page) => getLayout(page); type PostParams = { diff --git a/src/pages/blog/page/[number].tsx b/src/pages/blog/page/[number].tsx index fa1123d..e524a64 100644 --- a/src/pages/blog/page/[number].tsx +++ b/src/pages/blog/page/[number].tsx @@ -3,7 +3,7 @@ import type { ParsedUrlQuery } from 'querystring'; import type { GetStaticPaths, GetStaticProps } from 'next'; import Head from 'next/head'; import { useRouter } from 'next/router'; -import { useCallback } from 'react'; +import { type FC, useCallback } from 'react'; import { useIntl } from 'react-intl'; import { getLayout, @@ -78,23 +78,12 @@ type BlogPageProps = { translation: Messages; }; -/** - * Blog index page. - */ -const BlogPage: NextPageWithLayout<BlogPageProps> = ({ +const Blog: FC<Pick<BlogPageProps, 'data' | 'lastCursor' | 'pageNumber'>> = ({ data, lastCursor, pageNumber, }) => { - useRedirection({ - isReplacing: true, - to: ROUTES.BLOG, - whenPathMatches: (path) => - path === `${ROUTES.BLOG}${PAGINATED_ROUTE_PREFIX}/1`, - }); - const intl = useIntl(); - const { isFallback } = useRouter(); const { articles, error, @@ -256,8 +245,6 @@ const BlogPage: NextPageWithLayout<BlogPageProps> = ({ [intl] ); - if (isFallback) return <LoadingPage />; - const pageUrl = `${CONFIG.url}${ROUTES.BLOG}`; return ( @@ -359,6 +346,30 @@ const BlogPage: NextPageWithLayout<BlogPageProps> = ({ ); }; +/** + * Blog index page. + */ +const BlogPage: NextPageWithLayout<BlogPageProps> = ({ + data, + lastCursor, + pageNumber, +}) => { + useRedirection({ + isReplacing: true, + to: ROUTES.BLOG, + whenPathMatches: (path) => + path === `${ROUTES.BLOG}${PAGINATED_ROUTE_PREFIX}/1`, + }); + + const { isFallback } = useRouter(); + + return isFallback ? ( + <LoadingPage /> + ) : ( + <Blog data={data} lastCursor={lastCursor} pageNumber={pageNumber} /> + ); +}; + BlogPage.getLayout = (page) => getLayout(page); type BlogPageParams = { @@ -414,7 +425,8 @@ export const getStaticPaths: GetStaticPaths = async () => { { length: totalPages }, (_, index) => index + 1 ); - const paths = pagesArray.map((number) => { + // We remove /blog/page/1 since it is redirected to /blog + const paths = pagesArray.slice(1).map((number) => { return { params: { number: `${number}` } }; }); |
