GithubHelp home page GithubHelp logo

ok-mdx's Introduction

ok-mdx

Browser-based MDX editor

npm i -g ok-mdx
mkdir docs
touch docs/hello.mdx
mdx docs --open
  • Quickly prototype with React components
  • Zero configuration
  • Mix markdown with JSX
  • Live edit and autosave

What is this for?

MDX is great for documentation, building demos, or quickly prototyping with React components, without the need to set up a full-blown React application. Similar to Compositor x0, ok-mdx is meant to be installed as a global command line utility that you can use alongside your application setup or in isolated sandbox environments. ok-mdx works well as a local alternative to tools like CodeSandbox when working with React components.

Getting Started

ok-mdx needs a directory of .mdx or .md files to work.

After installing ok-mdx, create a folder and an empty .mdx file with the following command:

mkdir docs && touch docs/hello.mdx

Start the ok-mdx app:

mdx docs --open

This will open the application in your default browser, showing a list of the MDX files. Click on a filename to open the editor view. In the right panel, add some text to see the preview on the left.

MDX Format

MDX is a superset of markdown, which can also render JSX instead of HTML.

# Markdown Heading

<button className='blue'>JSX button</button>

Importing Components

In order to import components, be sure they're installed locally. This requires a package.json file in your current directory.

To create a package.json file, run npm init -y.

To install a component, use npm install. The following will install grid-styled and styled-components as a local dependency.

npm i grid-styled styled-components

To use components, import them at the top of your MDX file:

import { Flex, Box } from 'grid-styled'

# Hello

<Flex alignItems='center'>
  <Box p={3} width={1/2} bg='blue'>
    Flex
  </Box>
  <Box p={3} width={1/2}>
    Box
  </Box>
</Flex>

Options

-o --open     Opens development server in default browser
-p --port     Port for development server
--vim         Enable editor Vim mode

Exporting

ok-mdx is only meant to be used for development. To export your MDX files, consider one of the following tools:

  • Compositor x0: great for creating documentation, blogs, static sites, or other small demos
  • Next.js: great for creating production-ready, server-side rendered React applications

Related

ok-mdx's People

Contributors

jxnblk avatar romanhotsiy avatar vestimir 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.