aboutsummaryrefslogtreecommitdiffstats
path: root/src/services
Commit message (Collapse)AuthorAgeFilesLines
* test(services): add tests for createComment mutationArmand Philippot2023-12-112-32/+35
| | | | | * add Jest test * add a Cypress test in article pages spec
* refactor(pages): refine Contact pageArmand Philippot2023-12-112-16/+38
| | | | | | | * remove next/router dependency * remove pageTitle since it is defined in MDX * reduce statements by grouping messages * mock response with MSW and add test for sendEmail
* refactor(hooks): replace useGithubApi with useGithubRepoMetaArmand Philippot2023-12-073-0/+93
| | | | | | | | * use GraphQL API instead of REST (the inconvenient however is that we now need an authorization token...) * move fetcher in services * add tests * mock response using MSW
* refactor(pages): refine Topic pagesArmand Philippot2023-12-011-1/+2
| | | | | | * add useTopic and useTopicsList hooks to refresh data * add a table of contents * add Cypress tests
* refactor(pages): refine Thematic pagesArmand Philippot2023-12-016-35/+56
| | | | | | | | | | | * add a table of contents (however posts heading are not included) * rename posts list section title * add a useThematic hook to refresh thematic contents * add a useThematicLists hook to refresh thematics list * add a `notIn` filter in thematics list fetcher to directly remove unwanted thematics * add Cypress tests
* refactor(pages): refine Article pagesArmand Philippot2023-12-012-18/+13
| | | | | | | | | | | * use rehype to update code blocks class names * fix widget heading level (after a level 1 it should always be a level 2 and not 3) * replace Spinner with LoadingPage and LoadingPageComments components to keep layout coherent * refactor useArticle and useComments hooks * fix URLs in JSON LD schema * add Cypress tests
* refactor(pages): improve HomepageArmand Philippot2023-11-294-4/+4
| | | | | | | | | * move custom homepage components that does not require props to the MDX file (links should not need to be translated here but where they are defined) * move SEO title and meta desc to MDX file * make Page component the wrapper instead of using a React fragment * fix MDX module types
* fix(pages,services): make thematics & topics pages usable againArmand Philippot2023-11-2910-13/+698
| | | | | | | | | | When I refactored the fetchers and convertors in #f111685 I forgot to convert WPThematicPreview and WPTopicPreview so the thematics and topics pages was broken. I also: * removed the ToC added by error in #70b4f63 * fix heading styles * fix website url in topics pages
* fix(services,types): make queries and types coherent for TopicArmand Philippot2023-11-288-5/+109
| | | | | | * some nodes was missing in topicQuery * a node was mispelled in topicsListQuery * add tests for all topics fetchers
* fix(services,types): make coherent Thematic type and queryArmand Philippot2023-11-288-4/+113
| | | | | | * some nodes was queried but missing in the Thematic type and vice versa, it is now fixed * add tests for all thematics fetchers
* test(services): add tests for comments list fetcherArmand Philippot2023-11-282-1/+27
|
* test(services): add tests for posts fetchersArmand Philippot2023-11-2812-12/+159
|
* refactor(services): avoid nested fetchersArmand Philippot2023-11-283-12/+11
| | | | | | | If we use fetchPostsCount inside fetchAllPostsSlugs, we might have problems to test fetchAllPostsSlugs failure. So it is better to let the consumer pass the posts count as an argument. The same applies to thematics and topics.
* refactor(services, types): reorganize GraphQL fetchers and data typesArmand Philippot2023-11-2751-1350/+1866
| | | | | | | | | | | | 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-183-52/+59
| | | | | | | | | | | | | | | | | | | | 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(hooks): remove useSettings hookArmand Philippot2023-11-151-10/+9
| | | | | | | It does not make sense to re-export an existing object through a hook. On some pages both the hook and the object was imported... It is better to use the CONFIG (previously settings) object directly and by doing it we avoid potential errors because of conditional hooks.
* refactor(hooks): rewrite useLocalStorage hookArmand Philippot2023-11-113-26/+119
| | | | | | | * return a tuple instead of an object * add a validator function as parameter (if the stored value is manually changed, it is not safe to cast its type) * add tests
* refactor: use named export for everything except pagesArmand Philippot2023-09-207-40/+61
| | | | | | 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.
* refactor(build): replace paths aliases with relative pathsArmand Philippot2023-09-196-29/+32
| | | | | | Using paths aliases starting with "@" can be confusing and can lead to conflict with existings modules. I prefer to use relative paths to avoid extra configuration in tools because of these aliases.
* fix(comments): load all comments on a postArmand Philippot2022-08-212-53/+128
| | | | | | | | | Previously, only the first 10 comments was loaded. So I update the fetching method to retrieve all the comments on a post. Also, I choose to order comments on client side because of a bug with WPGraphQL. Finally, I renamed the Comment type to SingleComment to avoid conflict with existing types.
* refactor(types): move and rename GraphQL typesArmand Philippot2022-08-207-363/+113
| | | | | | | The api file in services was not really readable. So I move the types and I also rewrite a little the fetch function. I also rename most of the type to avoid conflict with preexisting types (like Node) and to keep consistency.
* fix: ensure all topics/thematics have the base urlArmand Philippot2022-05-233-4/+4
|
* refactor: reduce the number of data transformationArmand Philippot2022-05-236-29/+1
|
* chore: handle blog pagination when JS is disabledArmand Philippot2022-05-203-1/+48
|
* chore: handle settings changeArmand Philippot2022-05-181-3/+3
|
* chore: adjust and complete missing stylesArmand Philippot2022-05-162-0/+22
| | | | | | * add logo to topics pages and links * add Prism styles to articles * and a few other adjustements
* chore: add Article pagesArmand Philippot2022-05-153-1/+183
|
* chore: add Search pageArmand Philippot2022-05-154-9/+17
|
* chore: add Topic pagesArmand Philippot2022-05-132-6/+136
|
* chore: add Thematic pageArmand Philippot2022-05-132-2/+138
|
* chore: add blog page widgetsArmand Philippot2022-05-135-1/+107
|
* chore: handle blog paginationArmand Philippot2022-05-131-21/+45
|
* chore: add a Contact pageArmand Philippot2022-05-073-5/+72
|
* chore: add homepageArmand Philippot2022-05-031-3/+49
|
* chore: fetch posts for rss feedArmand Philippot2022-05-022-0/+105
|
* refactor: rewrite API fetching method and GraphQL queriesArmand Philippot2022-05-025-0/+650
|
* chore: remove old pages, components, helpers and typesArmand Philippot2022-04-293-642/+0
| | | | | Since I'm using new components, I will also rewrite the GraphQL queries so it is easier to start from scratch.
* refactor: update graphql queries (#14)Armand Philippot2022-03-091-28/+24
| | | | | | | | | | | | | | | | | | * refactor: replace postBy query postBy is now deprecated in WPGraphQL v1.7 * refactor: update post comments query PostBy is deprecated and it is now possible to use the post ID to query comments. * refactor: update get topic by slug query topicBy is deprecated * refactor: update get thematic by slug query thematicBy is deprecated
* feat: provide pagination for users with js disabled (#13)Armand Philippot2022-03-091-1/+28
| | | | | | | | | * chore: add a Pagination component * chore: add blog pages * chore: fallback to page number based navigation if JS disabled * chore: update translation
* chore: use a different configuration depending on app envArmand Philippot2022-03-041-1/+2
| | | | | | It will be useful with Docker. Instead of cloning the project with a different configuration, I can manage two different configuration thanks to dotenv and some checking inside the app.
* refactor: remove unused graphql fieldsArmand Philippot2022-02-141-45/+1
|
* fix: update comments list when a new comment is sendArmand Philippot2022-02-141-19/+41
| | | | | The comments list was static before. If an user posted a comment, even after it was approved, the comments list was keeping the old state.
* chore: improve RSS feed generation timeArmand Philippot2022-02-131-1/+16
|
* chore: add reading time in posts metaArmand Philippot2022-01-251-0/+24
|
* chore: display total found posts in page metaArmand Philippot2022-01-251-0/+1
|
* refactor(project): replace repo api call method with hook and swrArmand Philippot2022-01-241-15/+0
| | | | | | | | | | Instead of using post slug and an environment variable to fetch repo data, I use the given repo in each project MDX file. It allows me to fetch data from another user/organization if needed. To make it work, I no longer provide the full URL in MDX file. The new format is: "User/repo-slug". I also replaced the fetch method with SWR to improve caching and to avoid React complaining about cleanup useEffect.
* refactor: rename all subject occurrences into topicArmand Philippot2022-01-231-32/+32
| | | | | I change the name in graphql endpoint, so I decided to repercute this change here.
* chore: add a project summary componentArmand Philippot2022-01-201-0/+15
|
* chore: add a service to handle local storageArmand Philippot2022-01-171-0/+26
|
* fix(widget): remove items limit for ThematicsList and TopicsListArmand Philippot2022-01-111-2/+7
| | | | | | | By default WPGraphQL gets only the 10 first items if first is not specified. So some subjects was not displayed. I also add an order by title to the query. So I no longer need to sort arrays inside components.