Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
treeify-paths HTML example
node v4.9.1
version:
1.0.0
endpoint
share
tweet
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