aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/helpers/index.ts
Commit message (Collapse)AuthorAgeFilesLines
* refactor(services, types): reorganize GraphQL fetchers and data typesArmand Philippot2023-11-271-2/+1
| | | | | | | | | | | | The Typescript mapped types was useful for autocompletion in fetchers but their are harder to maintain. I think it's better to keep each query close to its fetcher to have a better understanding of the fetched data. So I: * colocate queries with their own fetcher * colocate mutations with their own mutator * remove Typescript mapped types for queries and mutations * move data convertors inside graphql services * rename most of data types and fetchers
* fix: generate an id for each headings in the page main contentsArmand Philippot2023-11-181-0/+1
| | | | | | | | | | | | | | | | | | | | Since #be4d907 the ids was no longer addded to headings in useHeadingsTree hook. It was a bad practice to manipulate the DOM that way. However, I did not move the implementation elsewhere... To fix this, I now use rehype-slug on both markdown contents and html string coming from WordPress. I'm not sure the dynamic imports are really useful here since the table of contents is on almost all pages but Jest was failing with regular import because of ESM. It is the only thing that makes the tests functional again so... However if we want to test the `updateContentTree` function, Jest fails for the same reason. So I decided to not test this function. I've already spend too much time on this issue. Another problem: the ToC on projects page. Currently we use the ref on the body but the page contents are imported dynamically so the hook is executed before the contents are loaded. It makes the ToC empty... We should refactor the pages so we can use the ref directly on the imported contents.
* refactor(components): rewrite PostsList componentArmand Philippot2023-11-131-0/+1
| | | | | | | | | | | | | | | * remove NoResults component and move logic to Search page * add a usePostsList hook * remove Pagination from PostsList (it is only used if javascript is disabled and not on every posts list) * replace `byYear` prop with `sortByYear` * replace `loadMore` prop with `onLoadMore` * remove `showLoadMoreBtn` (we can use `loadMore` prop instead to determine if we need to display the button) * replace `titleLevel` prop with `headingLvl` * add `firstNewResult` prop to handle focus on the new results when loading more article (we should not focus a useless span but the item directly)
* refactor(components): replace Summary component with PostPreviewArmand Philippot2023-11-111-0/+1
| | | | | | | | | | | * rename component to PostPreview because Summary is an HTML element and it could lead to confusion * replace `title` and `titleLevel` with `heading` and `headingLvl` because `title` is a native attribute * rename `intro` prop to `excerpt` * extract `cover` from `meta` prop * rewrite meta type * extract meta logic into a new component
* feat: replace next-themes with a custom ThemeProviderArmand Philippot2023-11-111-0/+1
| | | | | | | To be honest, next-themes was working fine. However since I use a theme provider for Prism code blocks, some code is duplicated between this app and the library. So I prefer to use a custom Provider without the options I don't need.
* feat(components): add a Time componentArmand Philippot2023-11-111-1/+0
| | | | | | Instead of using helpers functions to format the date each time we need to use a time element, it makes more sense to create a new component dedicated to this task.
* refactor: use named export for everything except pagesArmand Philippot2023-09-201-0/+7
Next expect a default export for pages so only those components should use default exports. Everything else should use named exports to reduce the number of import statements.