1.3.14 • Published 4 years ago

@casianojr/documentation v1.3.14

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
4 years ago

@lpgroup/docs

MDX parser library that returns styled JSX

Contents

Prerequisites

Requires plugin to use MDX. Example in Vite setup, vite.config.js

import { defineConfig } from 'vite'
import reactRefresh from '@vitejs/plugin-react-refresh'
import mdx from "vite-plugin-mdx";

export default defineConfig({
  plugins: [
    reactRefresh(),
    mdx()
]
})

Install

# via yarn
yarn add @lpgroup/docs

# via npm
npm install --save @lpgroup/docs

API

ParseMDXToFullDocs

This will convert MDXs to documentation format, clickable sidebar in the left and styled jsx in the right.

import React from 'react'
import ParseMDXToFullDocs from '@lpgroup/docs';
import HelloWorld1 from "./fiel1.mdx";
import HelloWorld2 from "./file2.mdx";
import HelloWorld3 from "./file3.mdx";

const Pages = () =>{
    return(
    <>
        <HelloWorld1/>
        <HelloWorld2/>
        <HelloWorld3/>
    </>
    )
}

const logo =() => <div>MyLogo</div>

function App() {
  return (
    <div>
      <ParseMDXToFullDocs
      drawerWidth={240}
      logo={logo}
      logoClassName={{margin: "10px"}}
      >
        <Pages />
      </ParseMDXToFullDocs>
    </div>
  )
}
propertytype, defaultdescription
drawerWidthnumber, 240the width of the drawer
logofunction, <></>Logo
logoClassNameobject, {}Style of the logo

MDXFormat

This is similar to ParseMDXToFullDocs, but without the sidebar, also will receive a props that will modify its display.

import {MDXFormat, mdxComponents} from '@lpgroup/docs'
const defineComponents = {
    ...mdxComponents,
    h1: (props) => <div style={{backgroundColor: "yellow", fontSize: "30px"}} {...props}/>
  }
     <MDXFormat
      customRender={defineComponents}
      elementTags={["h1", "h2", "p"]}
      >
        <Pages />
      </MDXFormat>
propertytype, defaultdescription
customRenderobject, mdxComponentcustomize the component render
elementTagsarray, "all"will only show the elements in the array

Possible element tags; "h1", "h2", "h3", "h4", "p", "li", "inlineCode", "code" "pre", "table", "all". The default is "all"

TagsArrayFilter

This will receive an array elementTags "all" and return a filtered mdx.

<MDXRootProvider>
    <TagsArrayFilter elementTags={["h2"]} >
        <Pages />
    </TagsArrayFilter>
</MDXRootProvider>

MDXRootProvider

Will allow the elements from mdx to be modified, all external styles are remove.

import {MDXRootProvider, mdxComponents} from '@lpgroup/docs'
const defineComponents = {
    ...mdxComponents,
    h1: (props) => <div style={{backgroundColor: "yellow", fontSize: "30px"}} {...props}/>
  }
<MDXRootProvider customRender={defineComponents}>
    <Pages/>
<MDXRootProvider>

default customRender is the mdxComponents

MDXProvider

import {MDXProvider} from '@lpgroup/docs'

See usage

mdxComponents

import {mdxComponents} from '@lpgroup/docs'
const components = {...mdxComponents, h1: ()=> }

This is default object that is used in the MDXRootProvider

Contribute

See contribute

License

MIT - See licence

1.3.0

4 years ago

1.3.14

4 years ago

1.3.11

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.1.12

4 years ago

1.1.11

4 years ago

1.1.10

4 years ago

1.0.98

4 years ago

1.0.97

4 years ago

1.0.96

4 years ago

1.0.95

4 years ago

1.0.94

4 years ago

1.0.93

4 years ago

1.0.92

4 years ago

1.0.91

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago