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, '/')