aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/helpers/format.ts17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/utils/helpers/format.ts b/src/utils/helpers/format.ts
index 9c6f266..71455b6 100644
--- a/src/utils/helpers/format.ts
+++ b/src/utils/helpers/format.ts
@@ -1,4 +1,4 @@
-import { ParamsSlug, Slug } from '@ts/types/app';
+import { ParamsIds, ParamsSlug, Slug } from '@ts/types/app';
import {
Article,
ArticlePreview,
@@ -293,3 +293,18 @@ export const getFormattedPaths = (array: Slug[]): ParamsSlug[] => {
return { params: { slug: object.slug } };
});
};
+
+/**
+ * Convert a number of pages to an array of params with ids.
+ * @param {number} totalPages - The total pages.
+ * @returns {ParamsIds} An array of params with ids.
+ */
+export const getFormattedPageNumbers = (totalPages: number): ParamsIds[] => {
+ const paths = [];
+
+ for (let i = 1; i <= totalPages; i++) {
+ paths.push({ params: { id: `${i}` } });
+ }
+
+ return paths;
+};