From c6bd92d5f91f80a3ee2ccfbc0db8895fa11febbe Mon Sep 17 00:00:00 2001 From: Maxime Quandalle Date: Wed, 11 Nov 2020 19:32:41 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Supprime=20l'obligation=20de=20d?= =?UTF-8?q?=C3=A9clarer=20les=20parents=20dans=20le=20Publicode=20Studio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Et lien local local vers le publicode Studio quand on est en développement local --- .../source/components/PublicodesBlock.tsx | 4 +++- publicodes/source/components/RuleLink.tsx | 24 +++++++++---------- publicodes/source/ruleUtils.ts | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/publicodes/source/components/PublicodesBlock.tsx b/publicodes/source/components/PublicodesBlock.tsx index aeb9dbae9..79a36f451 100644 --- a/publicodes/source/components/PublicodesBlock.tsx +++ b/publicodes/source/components/PublicodesBlock.tsx @@ -2,6 +2,8 @@ import React from 'react' import emoji from 'react-easy-emoji' export default function PublicodesBlock({ source }: { source: string }) { + const baseURL = + location.hostname === 'localhost' ? '/publicodes' : 'https://publi.codes' return (
{source} = Omit< @@ -46,13 +41,16 @@ export function RuleLink({ // if (!ruleWithDedicatedDocumentationPage(rule)) { // return makeJsx(engine.evaluate(rule.dottedName).formule) // } - - return ( - - {children || rule.title}{' '} - {displayIcon && rule.icons && {emoji(rule.icons)} } - - ) + if (rule) { + return ( + + {children || rule.title}{' '} + {displayIcon && rule.icons && {emoji(rule.icons)} } + + ) + } else { + return <>{nameLeaf(dottedName)} + } } export function RuleLinkWithContext( diff --git a/publicodes/source/ruleUtils.ts b/publicodes/source/ruleUtils.ts index a812d32c4..0d107d2a1 100644 --- a/publicodes/source/ruleUtils.ts +++ b/publicodes/source/ruleUtils.ts @@ -3,7 +3,7 @@ import { Rule, Rules } from './types' const splitName = (str: string) => str.split(' . ') const joinName = strs => strs.join(' . ') -export const nameLeaf = pipe(splitName, last) +export const nameLeaf = pipe(splitName, last) export const encodeRuleName = name => name ?.replace(/\s\.\s/g, '/')