docusaurus-theme-jarle-codeblock
Last updated 3 years ago by monastic.panic .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install docusaurus-theme-jarle-codeblock 
SYNC missed versions from official npm registry.

docusaurus-theme-jarle-codeblock

A Docusaurus theme for editable live code examples using JARLE.

Usage

Install

npm install docusaurus-theme-jarle-codeblock

Modify your docusaurus.config.js

module.exports = {
  ...
+ themes: ['docusaurus-theme-jarle-codeblock'],
  presets: ['@docusaurus/preset-classic']
  ...
}

Example in your markdown

```jsx live
function Clock(props) {
  const [date, setDate] = useState(new Date());
  useEffect(() => {
    var timerID = setInterval(() => tick(), 1000);

    return function cleanup() {
      clearInterval(timerID);
    };
  });

  function tick() {
    setDate(new Date());
  }

  return (
    <div>
      <h2>It is {date.toLocaleTimeString()}.</h2>
    </div>
  );
}
```

Handling local imports

By default import statements in a JARLE codeblock will use native ESM imports, which lets you use dependencies from online repositories like skypack.

If you want to use local dependencies bundling with your app instead, a "remark" plugin is provided to do some processing on Markdown code blocks to enable this.

Modify your docusaurus.config.js

module.exports = {
  themes: ['docusaurus-theme-jarle-codeblock'],
  presets: [
    [
      '@docusaurus/preset-classic',
      {
        docs: {
+          remarkPlugins: [require('docusaurus-theme-jarle-codeblock/remark')],
        },
        blog: {
+          remarkPlugins: [require('docusaurus-theme-jarle-codeblock/remark')],
        },
      },
    ],
  ],
  ...
};

This allows codeblocks like the following:

```jsx live
  import Button from '@site/src/components/Button';

  <Button>My Button</Button>
```

Current Tags

  • 1.7.4                                ...           latest (3 years ago)

12 Versions

  • 1.7.4                                ...           3 years ago
  • 1.7.3                                ...           3 years ago
  • 1.7.2                                ...           3 years ago
  • 1.7.1                                ...           3 years ago
  • 1.7.0                                ...           4 years ago
  • 1.6.0                                ...           4 years ago
  • 1.4.0                                ...           5 years ago
  • 1.2.0                                ...           5 years ago
  • 1.1.1                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.3                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 2
Last Day 0
Last Week 1
Last Month 12
Dependencies (5)
Dev Dependencies (3)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |