treeify-paths HTML example

node v4.9.1
version: 1.0.0
endpointsharetweet
https://github.com/khtdr/treeify-paths
const treeify = require('treeify-paths').default; const React = require('react'); const ReactDOMServer = require('react-dom/server'); let Dir = ({ node }) => ( <ul> {node.children.map(n => ( <li key={n.path}> {n.name ? <a href={n.path}>{n.name}</a> : n.path.split('/').pop()} {n.children.length? <Dir node={n} />:null} </li> ))} </ul> ); let paths = [ 'home.html', 'blog/2036/jan.html', 'blog/2036/feb.html', ]; ReactDOMServer.renderToStaticMarkup(<Dir node={treeify(paths)} />);
Loading…

no comments

    sign in to comment