From bb7d45cb97676627d266225b688dae070a204acd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rialland?= Date: Mon, 1 Aug 2022 12:55:31 +0200 Subject: [PATCH] Add documentation nav menu --- package.json | 3 ++- site/source/ServiceWorker.tsx | 2 +- site/source/pages/Documentation.tsx | 23 ++++++++++------------- yarn.lock | 6 +++--- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index 539273349..ad3990515 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,8 @@ "i18n:translate": "yarn workspace site i18n:translate" }, "resolutions": { - "@types/download/@types/got": "8.3.1" + "@types/download/@types/got": "8.3.1", + "publicodes-react": "betagouv/publicodes#head=add-rules-tree-nav&workspace=publicodes-react" }, "//": "@types/got:^9 is a hack to do a conflict with @types/download/@types/got and fix type error in download package https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/58929", "devDependencies": { diff --git a/site/source/ServiceWorker.tsx b/site/source/ServiceWorker.tsx index 9512b19d6..2ab452c7e 100644 --- a/site/source/ServiceWorker.tsx +++ b/site/source/ServiceWorker.tsx @@ -81,7 +81,7 @@ export const ServiceWorker = () => { onRegisterError: (error) => { // eslint-disable-next-line no-console - console.log('SW registration error', error) + console.error('SW registration error', error) }, }) diff --git a/site/source/pages/Documentation.tsx b/site/source/pages/Documentation.tsx index 8f7a6bad0..ebbd75c4c 100644 --- a/site/source/pages/Documentation.tsx +++ b/site/source/pages/Documentation.tsx @@ -15,7 +15,7 @@ import { RootState } from '@/reducers/rootReducer' import { useSitePaths } from '@/sitePaths' import rules, { DottedName } from 'modele-social' import { getDocumentationSiteMap, RulePage } from 'publicodes-react' -import React, { ComponentType, useMemo } from 'react' +import { ComponentProps, useMemo, useRef } from 'react' import { Helmet } from 'react-helmet-async' import { Trans, useTranslation } from 'react-i18next' import { useSelector } from 'react-redux' @@ -57,7 +57,7 @@ export default function MonEntrepriseRulePage() { name={documentationSitePaths[pathname]} /> - + @@ -77,6 +77,13 @@ function DocumentationPageBody() { const { i18n } = useTranslation() const params = useParams<{ '*': string }>() + const { current: renderers } = useRef({ + Head: Helmet, + Link, + Text: Markdown, + References, + } as ComponentProps['renderers']) + return ( , - Link: Link as ComponentType<{ - to: string - children: React.ReactNode - }>, - Text: Markdown, - References, - }} + renderers={renderers} /> ) diff --git a/yarn.lock b/yarn.lock index b92393d8a..cf1937906 100644 --- a/yarn.lock +++ b/yarn.lock @@ -23319,15 +23319,15 @@ __metadata: languageName: node linkType: hard -"publicodes-react@npm:^1.0.0-beta.46": +"publicodes-react@betagouv/publicodes#head=add-rules-tree-nav&workspace=publicodes-react": version: 1.0.0-beta.46 - resolution: "publicodes-react@npm:1.0.0-beta.46" + resolution: "publicodes-react@https://github.com/betagouv/publicodes.git#workspace=publicodes-react&commit=a6b3689ddf1842c5de9b9e3324e7d2adfa26f621" dependencies: styled-components: ^5.1.0 peerDependencies: publicodes: 1.0.0-beta.40 react: ^17 || ^18 - checksum: c335ef34060d333756fdff39eebe8827141edbe87ba097d380faeeda6f00c948f49cfd4961a249d417460001261933013cfc3ea2bfcaeb8bac79a81be807abf7 + checksum: 4f510360b0c9d65b214ab90d9a42a78cc1219917a615f347da775334c12592acfa6911626ab97f2f192b7c9436967475730dc6a5730e8f6d521dbc60ba2ade80 languageName: node linkType: hard