Repository URL to install this package:
|
Version:
0.9.5 ▾
|
import React from 'react'
import { stringify } from 'chain-able-boost'
import { Schema, DangerouslySetInnerHTML, DefaultProps } from './typings'
/**
* @class sameas JsonLd, but creating a factory is faster
*
* const script = React.createFactory('script')
* const JsonLdAttributes = {type: 'application/ld+json'}
* const JsonLd = props => script(JSON.stringify(props.data), JsonLdAttributes)
*/
/**
* @description ensure we have valid json data
*/
export function validateSchema(data: Schema): boolean {
// @todo
return false
}
/**
* simply create __html obj
*/
export function toInnerHTML(html: string): DangerouslySetInnerHTML {
return { __html: html }
}
/**
* turn props into innerHTML
*/
export function toStringifiedInnerHTML(props: DefaultProps): DangerouslySetInnerHTML {
const stringified = stringify(props.data || props)
const html = toInnerHTML(stringified)
return html
}