aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-11-20 12:27:46 +0100
committerArmand Philippot <git@armandphilippot.com>2023-11-20 19:32:09 +0100
commit70b4f633a6fbedb58c8b9134ac64ede854d489de (patch)
treec757bb12ad9a588e23b25cdb8b46710ac14dbcb1 /src/utils
parent9a481f066e1427d53a06cf7aeec525a745abf03f (diff)
refactor(components): replace PageLayout template with Page
* split pages in smaller components (it is both easier to maintain and more readable, we avoid the use of fragments in pages directory) * extract breadcrumbs from article tag (the navigation is not related to the page contents) * remove useReadingTime hook * remove layout options except `isHome`
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/hooks/index.ts1
-rw-r--r--src/utils/hooks/use-reading-time.tsx56
2 files changed, 0 insertions, 57 deletions
diff --git a/src/utils/hooks/index.ts b/src/utils/hooks/index.ts
index b3fa627..240a092 100644
--- a/src/utils/hooks/index.ts
+++ b/src/utils/hooks/index.ts
@@ -17,7 +17,6 @@ export * from './use-pagination';
export * from './use-posts-list';
export * from './use-prism';
export * from './use-prism-theme';
-export * from './use-reading-time';
export * from './use-redirection';
export * from './use-reduced-motion';
export * from './use-scroll-lock';
diff --git a/src/utils/hooks/use-reading-time.tsx b/src/utils/hooks/use-reading-time.tsx
deleted file mode 100644
index 3a812f6..0000000
--- a/src/utils/hooks/use-reading-time.tsx
+++ /dev/null
@@ -1,56 +0,0 @@
-import { useIntl } from 'react-intl';
-
-/**
- * Retrieve the estimated reading time by words count.
- *
- * @param {number} wordsCount - The number of words.
- * @returns {string} The estimated reading time.
- */
-export const useReadingTime = (
- wordsCount: number,
- onlyMinutes: boolean = false
-): string => {
- const intl = useIntl();
- const wordsPerMinute = 245;
- const wordsPerSecond = wordsPerMinute / 60;
- const estimatedTimeInSeconds = wordsCount / wordsPerSecond;
-
- if (onlyMinutes) {
- const estimatedTimeInMinutes = Math.round(estimatedTimeInSeconds / 60);
-
- return intl.formatMessage(
- {
- defaultMessage: '{minutesCount} minutes',
- description: 'useReadingTime: rounded minutes count',
- id: 's1i43J',
- },
- { minutesCount: estimatedTimeInMinutes }
- );
- } else {
- const estimatedTimeInMinutes = Math.floor(estimatedTimeInSeconds / 60);
-
- if (estimatedTimeInMinutes <= 0) {
- return intl.formatMessage(
- {
- defaultMessage: '{count} seconds',
- description: 'useReadingTime: seconds count',
- id: 'i7Wq3G',
- },
- { count: estimatedTimeInSeconds.toFixed(0) }
- );
- }
-
- const remainingSeconds = Math.round(
- estimatedTimeInSeconds - estimatedTimeInMinutes * 60
- ).toFixed(0);
-
- return intl.formatMessage(
- {
- defaultMessage: '{minutesCount} minutes {secondsCount} seconds',
- description: 'useReadingTime: minutes + seconds count',
- id: 'OevMeU',
- },
- { minutesCount: estimatedTimeInMinutes, secondsCount: remainingSeconds }
- );
- }
-};