import React from 'react'; import ReactDOM from 'react-dom'; import ReactMarkdown from 'react-markdown'; import { Switch, Route, HashRouter, Link } from 'react-router-dom'; const markdown = require('./markdown.json'); const intro = ` Cette appli est un petit guide pour débuter en JavaScript, qui s'adresse à ceux qui connaissent déjà un autre langage - Java en l'occurence. On va présenter les bases nécessaires pour interagir avec une page web, sans entrer dans les détails du langage. Précisons que le fait qu'il soit disponible sur tous les navigateurs et machines (ordinateurs, tablettes, smartphones), fait de JavaScript la plate-forme d'exécution de programmes **la plus répandue**. `; class Page extends React.Component { componentDidMount() { Prism.highlightAll(); $('.page ul').addClass('browser-default'); } render() { const { title, content } = this.props.page; const { section } = this.props; return (
home {section.title} {title}

{title}

); } } class Home extends React.Component { render() { return (
home Accueil

Accueil

{getSectionLinks()}
); } } function getSection(sectionIndex) { const section = markdown[sectionIndex]; return () => (
home {section.title}

{section.title}

{getSectionPageLinks(section)}
); } function getSectionPagination(section, activeIndex) { const lastIndex = section.items.length - 1; const previousHref = activeIndex === 0 ? section.path : section.path + section.items[activeIndex - 1].path; const nextHref = activeIndex === lastIndex ? section.path : section.path + section.items[activeIndex + 1].path; return (
); } function getPage(sectionIndex, pageIndex) { const section = markdown[sectionIndex]; const page = section.items[pageIndex]; return () => (
{getSectionPagination(section, pageIndex)}
); } function getSectionPageLinks(section) { return ( ); } function getSectionLinks() { return ( ); } function getSectionRoutes(section, sIndex) { const routes = [{ key: sIndex, path: section.path, component: getSection(sIndex) }].concat(section.items.map((page, pIndex) => ({ key: sIndex + '-' + pIndex, path: section.path + page.path, component: getPage(sIndex, pIndex) }))); // return ; return routes.map(r => ); } ReactDOM.render(
{/*}
    { markdown.map((section, sIndex) => (
  • {section.title} {getSectionPageLinks(section)}
  • )) }
  • Home
*/} { markdown.map(getSectionRoutes) }
, document.getElementById('root') );