aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/helpers
Commit message (Collapse)AuthorAgeFilesLines
* refactor(pages): refine Article pagesArmand Philippot2023-12-012-14/+124
| | | | | | | | | | | * 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): refine RSS feedArmand Philippot2023-11-302-7/+59
| | | | | | | | | | | * add favicon * add item categories * add item image * add item author * add item update date (it seems `date` is used as update date by Feed) * change copyright format * fix ESlint errors * fix atom and json links
* refactor(pages): improve HomepageArmand Philippot2023-11-292-20/+34
| | | | | | | | | * 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-291-0/+8
| | | | | | | | | | 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
* refactor(services, types): reorganize GraphQL fetchers and data typesArmand Philippot2023-11-277-161/+100
| | | | | | | | | | | | 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: remove rehype-sanitize to avoid broken layoutsArmand Philippot2023-11-201-2/+0
| | | | | | | The `rehype-sanitize` plugin was removing some tags inside the post contents coming from WordPress so the layout was broken. This plugin is useful to avoid DOM clobbering but I trust rehype-slug and myself so it is safe to remove it.
* fix: generate an id for each headings in the page main contentsArmand Philippot2023-11-184-5/+31
| | | | | | | | | | | | | | | | | | | | 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-153-33/+33
| | | | | | | 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(components): replace LinksListWidget with LinksWidgetArmand Philippot2023-11-141-3/+4
| | | | | | | * avoid List component repeat * rewrite tests and CSS * add an id to LinksWidgetItemData (previously LinksListItems) type because the label could be duplicated
* refactor(components): rewrite PostsList componentArmand Philippot2023-11-133-0/+45
| | | | | | | | | | | | | | | * 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-114-7/+107
| | | | | | | | | | | * 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
* refactor(providers,hooks): rewrite PrismThemeProvider & usePrismThemeArmand Philippot2023-11-111-0/+7
| | | | | | * reuse Theme provider logic * move DOM mutation from provider to hook * add a script to init theme before page load
* feat: replace next-themes with a custom ThemeProviderArmand Philippot2023-11-112-0/+19
| | | | | | | 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.
* refactor(hooks,provider): move reduce motion setterArmand Philippot2023-11-111-12/+20
| | | | | | | | | | Since the local storage key is not meant to change between the components, it should be set directly inside the app file. So both the local storage and the data attribute should be handle in a provider. I also added a custom document because we need a script to retrieve the stored value in local storage earlier to avoid flashing on hydration.
* feat(components): add a Time componentArmand Philippot2023-11-112-41/+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(routes): replace hardcoded routes with constantsArmand Philippot2023-10-243-34/+37
| | | | | | | | It makes it easier to change a route if needed and it avoid typo mistakes. I also refactored a bit the concerned files to be complient with the new ESlint config. However, I should rewrite the pages to reduce the number of statements.
* refactor: use named export for everything except pagesArmand Philippot2023-09-209-39/+31
| | | | | | 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-198-22/+22
| | | | | | 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.
* refactor(types): move and rename GraphQL typesArmand Philippot2022-08-201-1/+17
| | | | | | | 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.
* chore: use image title as figure label if no caption is providedArmand Philippot2022-06-071-0/+1
|
* fix: ensure all topics/thematics have the base urlArmand Philippot2022-05-231-10/+6
|
* refactor(schema): use helpers function to avoid repeat between pagesArmand Philippot2022-05-231-0/+224
|
* refactor: reduce the number of data transformationArmand Philippot2022-05-231-17/+32
|
* refactor: rewrite Prism hooks and providersArmand Philippot2022-05-191-0/+10
| | | | | It avoid some hydratation errors on project pages (not in article however) and the hooks are now reusable.
* chore: adjust and complete missing stylesArmand Philippot2022-05-161-1/+4
| | | | | | * add logo to topics pages and links * add Prism styles to articles * and a few other adjustements
* chore: add Thematic pageArmand Philippot2022-05-131-1/+46
|
* chore: handle blog paginationArmand Philippot2022-05-131-2/+11
|
* chore: add Project single pagesArmand Philippot2022-05-133-50/+77
|
* refactor: rewrite DescriptionList and Meta componentsArmand Philippot2022-05-091-15/+0
| | | | | | The meta can have different layout. The previous implementation was not enough to easily change the layout. Also, I prefer to restrict the meta types and it prevents me to repeat myself for the labels.
* chore: add a Projects pageArmand Philippot2022-05-051-0/+85
|
* chore: add a LegalNotice pageArmand Philippot2022-05-031-5/+5
|
* chore: fetch posts for rss feedArmand Philippot2022-05-025-19/+156
|
* chore: remove old pages, components, helpers and typesArmand Philippot2022-04-295-474/+1
| | | | | Since I'm using new components, I will also rewrite the GraphQL queries so it is easier to start from scratch.
* chore: add a PageLayout componentArmand Philippot2022-04-251-3/+25
|
* refactor: load prism plugins without babelArmand Philippot2022-03-241-11/+10
|
* refactor: update graphql queries (#14)Armand Philippot2022-03-091-3/+3
| | | | | | | | | | | | | | | | | | * 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/+16
| | | | | | | | | * 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-7/+6
| | | | | | 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.
* feat: add HTTP security headersArmand Philippot2022-02-151-3/+3
| | | | | I also renamed and changed the format of some environment variables so I can reuse them inside the CSP security header.
* fix: update comments list when a new comment is sendArmand Philippot2022-02-141-8/+6
| | | | | 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(matomo): use another dependency to track page viewsArmand Philippot2022-02-141-7/+0
| | | | | | I though the previous package would track all visits with the provided but it seems that I need to add trackPageView on all pages. So I decided to use another package.
* chore: improve RSS feed generation timeArmand Philippot2022-02-131-10/+5
|
* fix(prism): translate toolbar buttons on single article pagesArmand Philippot2022-02-101-49/+0
| | | | | The translation was not always loaded the first time. So I decided to put the prism attributes manually instead.
* chore(prism): translate color scheme toggle buttonArmand Philippot2022-02-081-0/+21
|
* fix: handle getStaticPaths fallbackArmand Philippot2022-02-021-0/+12
| | | | | | | | I had errors with next build because of fallback. I need to return early if the path does not exists, if not Next complains about undefined variables. I don't think it was related but I also fix the paths format in getStaticPaths, I forgot the params object in some dynamic routes.
* chore: add MatomoArmand Philippot2022-01-311-0/+7
|
* chore(baseline): handle baseline translation manuallyArmand Philippot2022-01-301-1/+1
| | | | | | I cannot use formatjs to translate the website baseline since I need an async function to load the message. If I use the getIntlInstance helper outside NextJS, webpack is complaining about fs and path.
* refactor(config): move config from config dir to utilsArmand Philippot2022-01-292-7/+7
|
* chore: replace lingui functions with react-intlArmand Philippot2022-01-292-6/+39
|
* chore(i18n): replace i18n provider and helpersArmand Philippot2022-01-291-75/+17
|