Code Monkey home page Code Monkey logo

live-doc's Introduction

live-doc

Convert markdown to live React demos http://jxnblk.com/live-doc

Built with: react-markdown, React Live, Rebass, and styled-components

Getting Started

npm i -g live-doc

Convert a markdown file to a React app and save as index.html:

doc README.md

Live Code Example

By using the .jsx language attribute at the beginning of a code block, live-doc will convert the example into a live-editable example using React Live.

<div>
  <Heading color='tomato'>
    Hello! Edit me
  </Heading>
  <button
    onClick={e => {
      alert('Hello')
    }}
    children='Beep'
  />
</div>

In this example, the Rebass Heading component has been added to the scope in the docs/config.js file, making it available to the React Live preview.

React Live noInline Mode

To enable the noInline mode in React Live, use the ..jsx language attribute at the beginning of a code block.

const Hello = () => <h1>Hello</h1>

const App = () => (
  <div>
    <Hello />
    <button
      onClick={e => {
        alert('Beep')
      }}
      children='Beep'
    />
  </div>
)

render(<App />)

CLI Options

-d --out-dir    Output directory
-c --config     Path to config file

Configuration

To customize the output React app, create a config file that exports an object.

// config.js
module.exports = {
  // Scope for react-live previews
  scope: {
    foo: 'Hello'
  },
  title: 'Page Title',
  css: 'body { color: tomato }',
  script: 'console.log("Hello");',
  // Meta tags
  meta: [
    {
      name: 'og:image',
      content: 'kitten.jpg'
    }
  ]
}

Then pass the file with the --config flag to the CLI.

doc README.md --config config.js

GitHub Made by Jxnblk

MIT License

live-doc's People

Contributors

jxnblk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.