aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/helpers/format.ts8
-rw-r--r--src/utils/hooks/useHeadingsTree.tsx7
2 files changed, 4 insertions, 11 deletions
diff --git a/src/utils/helpers/format.ts b/src/utils/helpers/format.ts
index 94aa2e7..44536dd 100644
--- a/src/utils/helpers/format.ts
+++ b/src/utils/helpers/format.ts
@@ -61,15 +61,11 @@ export const getFormattedPostPreview = (rawPost: RawArticlePreview) => {
export const getFormattedPostsList = (
rawPosts: RawArticlePreview[]
): ArticlePreview[] => {
- const formattedPosts = rawPosts
+ return rawPosts
.filter((post) => Object.getOwnPropertyNames(post).length > 0)
.map((post) => {
- const formattedPost = getFormattedPostPreview(post);
-
- return formattedPost;
+ return getFormattedPostPreview(post);
});
-
- return formattedPosts;
};
/**
diff --git a/src/utils/hooks/useHeadingsTree.tsx b/src/utils/hooks/useHeadingsTree.tsx
index 94d3b4b..745ba23 100644
--- a/src/utils/hooks/useHeadingsTree.tsx
+++ b/src/utils/hooks/useHeadingsTree.tsx
@@ -8,9 +8,7 @@ const useHeadingsTree = (wrapper: string) => {
const getElementDepth = useCallback(
(el: HTMLHeadingElement) => {
- const elDepth = depths.findIndex((depth) => depth === el.localName);
-
- return elDepth;
+ return depths.findIndex((depth) => depth === el.localName);
},
[depths]
);
@@ -73,9 +71,8 @@ const useHeadingsTree = (wrapper: string) => {
const getHeadingsList = useCallback(
(headings: NodeListOf<HTMLHeadingElement>): Heading[] => {
const formattedHeadings = formatHeadings(headings);
- const headingsList = buildTree(formattedHeadings);
- return headingsList;
+ return buildTree(formattedHeadings);
},
[formatHeadings, buildTree]
);