🐛 Supprime l'obligation de déclarer les parents dans le Publicode Studio
Et lien local local vers le publicode Studio quand on est en développement localpull/1201/head
parent
b105933234
commit
c6bd92d5f9
|
@ -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 (
|
||||
<div
|
||||
css={`
|
||||
|
@ -12,7 +14,7 @@ export default function PublicodesBlock({ source }: { source: string }) {
|
|||
<code>{source}</code>
|
||||
</pre>
|
||||
<a
|
||||
href={`https://publi.codes/studio?code=${encodeURIComponent(source)}`}
|
||||
href={`${baseURL}/studio?code=${encodeURIComponent(source)}`}
|
||||
target="_blank"
|
||||
css={`
|
||||
position: absolute;
|
||||
|
|
|
@ -2,12 +2,7 @@ import React, { useContext } from 'react'
|
|||
import emoji from 'react-easy-emoji'
|
||||
import { Link } from 'react-router-dom'
|
||||
import Engine from '..'
|
||||
import { makeJsx } from '../evaluation'
|
||||
import {
|
||||
encodeRuleName,
|
||||
ruleParents,
|
||||
ruleWithDedicatedDocumentationPage
|
||||
} from '../ruleUtils'
|
||||
import { encodeRuleName, nameLeaf } from '../ruleUtils'
|
||||
import { BasepathContext, EngineContext } from './contexts'
|
||||
|
||||
type RuleLinkProps<Name extends string> = Omit<
|
||||
|
@ -46,13 +41,16 @@ export function RuleLink<Name extends string>({
|
|||
// if (!ruleWithDedicatedDocumentationPage(rule)) {
|
||||
// return makeJsx(engine.evaluate(rule.dottedName).formule)
|
||||
// }
|
||||
|
||||
return (
|
||||
<Link to={newPath} {...props}>
|
||||
{children || rule.title}{' '}
|
||||
{displayIcon && rule.icons && <span>{emoji(rule.icons)} </span>}
|
||||
</Link>
|
||||
)
|
||||
if (rule) {
|
||||
return (
|
||||
<Link to={newPath} {...props}>
|
||||
{children || rule.title}{' '}
|
||||
{displayIcon && rule.icons && <span>{emoji(rule.icons)} </span>}
|
||||
</Link>
|
||||
)
|
||||
} else {
|
||||
return <>{nameLeaf(dottedName)}</>
|
||||
}
|
||||
}
|
||||
|
||||
export function RuleLinkWithContext(
|
||||
|
|
|
@ -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<string, string[], string>(splitName, last)
|
||||
export const encodeRuleName = name =>
|
||||
name
|
||||
?.replace(/\s\.\s/g, '/')
|
||||
|
|
Loading…
Reference in New Issue