aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components/organisms/posts-list/posts-list.tsx6
-rw-r--r--src/components/templates/layout/layout.tsx11
-rw-r--r--src/i18n/en.json20
-rw-r--r--src/i18n/fr.json20
-rw-r--r--src/pages/blog/index.tsx21
-rw-r--r--src/pages/blog/page/[number].tsx33
6 files changed, 58 insertions, 53 deletions
diff --git a/src/components/organisms/posts-list/posts-list.tsx b/src/components/organisms/posts-list/posts-list.tsx
index ad5bed5..91b2e0d 100644
--- a/src/components/organisms/posts-list/posts-list.tsx
+++ b/src/components/organisms/posts-list/posts-list.tsx
@@ -222,7 +222,8 @@ const PostsListWithRef: ForwardRefRenderFunction<
{total ? (
<ProgressBar
aria-label={progressInfo}
- className={styles.progress}
+ // eslint-disable-next-line react/jsx-no-literals
+ className={`${styles.progress} js-only`}
current={posts.length}
isCentered
isLoading={isLoading}
@@ -232,7 +233,8 @@ const PostsListWithRef: ForwardRefRenderFunction<
) : null}
{onLoadMore && (!total || (total && posts.length < total)) ? (
<Button
- className={styles.btn}
+ // eslint-disable-next-line react/jsx-no-literals
+ className={`${styles.btn} js-only`}
isLoading={isLoading}
// eslint-disable-next-line react/jsx-no-literals
kind="tertiary"
diff --git a/src/components/templates/layout/layout.tsx b/src/components/templates/layout/layout.tsx
index 16c9180..19cefce 100644
--- a/src/components/templates/layout/layout.tsx
+++ b/src/components/templates/layout/layout.tsx
@@ -1,3 +1,4 @@
+import Head from 'next/head';
import {
useRef,
type FC,
@@ -53,6 +54,16 @@ export const Layout: FC<LayoutProps> = ({ children, isHome }) => {
return (
<>
+ <Head>
+ <noscript>
+ <style>
+ {/* eslint-disable-next-line react/jsx-no-literals */}
+ {`.js-only {
+ display: none !important;
+ }`}
+ </style>
+ </noscript>
+ </Head>
<span id={topId} ref={topRef} tabIndex={-1} />
<noscript>
<div className={styles['noscript-spacing']} />
diff --git a/src/i18n/en.json b/src/i18n/en.json
index 411bb06..2541c9c 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -227,10 +227,6 @@
"defaultMessage": "No results found. Would you like to try a new search?",
"description": "SearchPage: no results"
},
- "EET/tC": {
- "defaultMessage": "Loading the repository metadata...",
- "description": "ProjectPage: loading repository metadata"
- },
"EH+dam": {
"defaultMessage": "404: Not found",
"description": "UseBreadcrumbs: page not found label"
@@ -371,6 +367,10 @@
"defaultMessage": "Topics are loading...",
"description": "BlogPage: loading topics message"
},
+ "OzVOKP": {
+ "defaultMessage": "Loading the repository creation date...",
+ "description": "ProjectPage: loading repository metadata"
+ },
"PnrHgZ": {
"defaultMessage": "Home",
"description": "SiteNavbar: main nav - home link"
@@ -407,6 +407,10 @@
"defaultMessage": "License:",
"description": "ProjectOverview: license label"
},
+ "RfXzNe": {
+ "defaultMessage": "Loading the repository popularity...",
+ "description": "ProjectPage: loading repository metadata"
+ },
"Sm2wCk": {
"defaultMessage": "LinkedIn profile",
"description": "CVPage: LinkedIn profile link"
@@ -419,6 +423,10 @@
"defaultMessage": "It has been approved.",
"description": "PageComments: comment approved."
},
+ "VEHEEs": {
+ "defaultMessage": "Loading the repository update date...",
+ "description": "ProjectPage: loading repository metadata"
+ },
"VTJE8h": {
"defaultMessage": "{author}'s avatar",
"description": "Article: accessible name for the comment avatar"
@@ -475,10 +483,6 @@
"defaultMessage": "Name:",
"description": "CommentForm: name label"
},
- "ZMES/E": {
- "defaultMessage": "You can't load more articles without Javascript, please use the pagination instead.",
- "description": "BlogPage: pagination no script message"
- },
"ZcFroC": {
"defaultMessage": "Thanks, your comment was successfully sent.",
"description": "PageComments: comment form success message"
diff --git a/src/i18n/fr.json b/src/i18n/fr.json
index 399abcf..656f57c 100644
--- a/src/i18n/fr.json
+++ b/src/i18n/fr.json
@@ -227,10 +227,6 @@
"defaultMessage": "Aucun résultat. Souhaitez-vous tenter une nouvelle rechercher ?",
"description": "SearchPage: no results"
},
- "EET/tC": {
- "defaultMessage": "Chargement des métadonnées du dépôt…",
- "description": "ProjectPage: loading repository metadata"
- },
"EH+dam": {
"defaultMessage": "404: Non trouvé",
"description": "UseBreadcrumbs: page not found label"
@@ -371,6 +367,10 @@
"defaultMessage": "Les sujets sont en cours de chargement…",
"description": "BlogPage: loading topics message"
},
+ "OzVOKP": {
+ "defaultMessage": "La date de création du dépôt est en cours de chargement…",
+ "description": "ProjectPage: loading repository metadata"
+ },
"PnrHgZ": {
"defaultMessage": "Accueil",
"description": "SiteNavbar: main nav - home link"
@@ -407,6 +407,10 @@
"defaultMessage": "Licence :",
"description": "ProjectOverview: license label"
},
+ "RfXzNe": {
+ "defaultMessage": "La popularité du dépôt est en cours de chargement…",
+ "description": "ProjectPage: loading repository metadata"
+ },
"Sm2wCk": {
"defaultMessage": "Profil LinkedIn",
"description": "CVPage: LinkedIn profile link"
@@ -419,6 +423,10 @@
"defaultMessage": "Il a été approuvé.",
"description": "PageComments: comment approved."
},
+ "VEHEEs": {
+ "defaultMessage": "La date de mise à jour du dépôt est en cours de chargement…",
+ "description": "ProjectPage: loading repository metadata"
+ },
"VTJE8h": {
"defaultMessage": "Avatar de {author}",
"description": "Article: accessible name for the comment avatar"
@@ -475,10 +483,6 @@
"defaultMessage": "Nom :",
"description": "CommentForm: name label"
},
- "ZMES/E": {
- "defaultMessage": "Vous ne pouvez pas charger plus d’articles sans Javascript, veuillez utiliser la pagination.",
- "description": "BlogPage: pagination no script message"
- },
"ZcFroC": {
"defaultMessage": "Merci, votre commentaire a été envoyé avec succès.",
"description": "PageComments: comment form success message"
diff --git a/src/pages/blog/index.tsx b/src/pages/blog/index.tsx
index f58d36f..0451bd7 100644
--- a/src/pages/blog/index.tsx
+++ b/src/pages/blog/index.tsx
@@ -55,8 +55,11 @@ import {
useTopicsList,
} from '../../utils/hooks';
-const renderPaginationLink: RenderPaginationLink = (pageNum) =>
- `${ROUTES.BLOG}${PAGINATED_ROUTE_PREFIX}/${pageNum}`;
+const renderPaginationLink: RenderPaginationLink = (pageNum) => {
+ if (pageNum === 1) return ROUTES.BLOG;
+
+ return `${ROUTES.BLOG}${PAGINATED_ROUTE_PREFIX}/${pageNum}`;
+};
type BlogPageProps = {
data: {
@@ -113,12 +116,6 @@ const BlogPage: NextPageWithLayout<BlogPageProps> = ({ data }) => {
id: '7TbbIk',
}),
pagination: {
- noJS: intl.formatMessage({
- defaultMessage:
- "You can't load more articles without Javascript, please use the pagination instead.",
- description: 'BlogPage: pagination no script message',
- id: 'ZMES/E',
- }),
title: intl.formatMessage({
defaultMessage: 'Pagination',
description: 'BlogPage: pagination accessible name',
@@ -276,12 +273,6 @@ const BlogPage: NextPageWithLayout<BlogPageProps> = ({ data }) => {
</Notice>
) : null}
<noscript>
- <Notice
- // eslint-disable-next-line react/jsx-no-literals
- kind="info"
- >
- {messages.pagination.noJS}
- </Notice>
<Pagination
aria-label={messages.pagination.title}
className={styles.pagination}
@@ -289,7 +280,7 @@ const BlogPage: NextPageWithLayout<BlogPageProps> = ({ data }) => {
isCentered
renderItemAriaLabel={renderPaginationLabel}
renderLink={renderPaginationLink}
- total={data.posts.pageInfo.total}
+ total={Math.ceil(data.posts.pageInfo.total / CONFIG.postsPerPage)}
/>
</noscript>
</PageBody>
diff --git a/src/pages/blog/page/[number].tsx b/src/pages/blog/page/[number].tsx
index e524a64..d06e663 100644
--- a/src/pages/blog/page/[number].tsx
+++ b/src/pages/blog/page/[number].tsx
@@ -64,14 +64,18 @@ import {
useTopicsList,
} from '../../../utils/hooks';
-const renderPaginationLink: RenderPaginationLink = (pageNum) =>
- `${ROUTES.BLOG}${PAGINATED_ROUTE_PREFIX}/${pageNum}`;
+const renderPaginationLink: RenderPaginationLink = (pageNum) => {
+ if (pageNum === 1) return ROUTES.BLOG;
+
+ return `${ROUTES.BLOG}${PAGINATED_ROUTE_PREFIX}/${pageNum}`;
+};
type BlogPageProps = {
data: {
posts: GraphQLConnection<WPPostPreview>;
thematics: GraphQLConnection<WPThematicPreview>;
topics: GraphQLConnection<WPTopicPreview>;
+ totalPosts: number;
};
lastCursor: Maybe<Nullable<string>>;
pageNumber: number;
@@ -131,12 +135,6 @@ const Blog: FC<Pick<BlogPageProps, 'data' | 'lastCursor' | 'pageNumber'>> = ({
}
),
pagination: {
- noJS: intl.formatMessage({
- defaultMessage:
- "You can't load more articles without Javascript, please use the pagination instead.",
- description: 'BlogPage: pagination no script message',
- id: 'ZMES/E',
- }),
title: intl.formatMessage({
defaultMessage: 'Pagination',
description: 'BlogPage: pagination accessible name',
@@ -266,7 +264,7 @@ const Blog: FC<Pick<BlogPageProps, 'data' | 'lastCursor' | 'pageNumber'>> = ({
</Head>
<PageHeader
heading={messages.pageTitle}
- meta={{ total: data.posts.pageInfo.total }}
+ meta={{ total: data.totalPosts }}
/>
<PageBody>
{articles ? (
@@ -295,12 +293,6 @@ const Blog: FC<Pick<BlogPageProps, 'data' | 'lastCursor' | 'pageNumber'>> = ({
</Notice>
) : null}
<noscript>
- <Notice
- // eslint-disable-next-line react/jsx-no-literals
- kind="info"
- >
- {messages.pagination.noJS}
- </Notice>
<Pagination
aria-label={messages.pagination.title}
className={styles.pagination}
@@ -308,7 +300,7 @@ const Blog: FC<Pick<BlogPageProps, 'data' | 'lastCursor' | 'pageNumber'>> = ({
isCentered
renderItemAriaLabel={renderPaginationLabel}
renderLink={renderPaginationLink}
- total={data.posts.pageInfo.total}
+ total={Math.ceil(data.totalPosts / CONFIG.postsPerPage)}
/>
</noscript>
</PageBody>
@@ -390,10 +382,10 @@ export const getStaticProps: GetStaticProps<BlogPageProps> = async ({
},
};
- const lastCursor =
- pageNumber > 1
- ? await fetchLastPostCursor(CONFIG.postsPerPage * (pageNumber - 1))
- : null;
+ const lastCursor = await fetchLastPostCursor(
+ CONFIG.postsPerPage * (pageNumber - 1)
+ );
+ const totalPosts = await fetchPostsCount();
const posts = await fetchPostsList({
first: CONFIG.postsPerPage,
after: lastCursor,
@@ -410,6 +402,7 @@ export const getStaticProps: GetStaticProps<BlogPageProps> = async ({
posts: JSON.parse(JSON.stringify(posts)),
thematics,
topics,
+ totalPosts,
},
lastCursor,
pageNumber,