docusaurus/packages/docusaurus-theme-live-codeb...
Sébastien Lorber 4a2200ace4
chore: backport retro compatible commits for the Docusaurus v2.4.1 release (#8979)
Co-authored-by: Tarun Chauhan <tarun.chauhan@tripjack.com>
Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com>
Co-authored-by: Sachin Nanayakkara <sachinnanayakkara21@gmail.com>
Co-authored-by: Tarun Chauhan <tarunrajput1337@gmail.com>
Co-authored-by: Armano <armano2@users.noreply.github.com>
Co-authored-by: Aleksandr Vladykin <morsko1@yandex.ru>
Co-authored-by: Andrew Lyons <andrew@nicols.co.uk>
Co-authored-by: MetuMortis <78408599+LiberaTeMetuMortis@users.noreply.github.com>
fix(create): add missing await (#8831)
fix(theme-translations): remove redundant navigation text in aria label (#8842)
fix(utils): handle Markdown links with spaces to route correctly (#8874)
fix(theme-common): fix confusing theme error message: bad sidebar id suggestions (#8873)
fix(theme-common): fix collapsible component with prefers-reduced-motion (#8906)
fix(theme): add __ prefix to technical anchors, search crawlers (Algolia) should ignore them (#8909)
fix(core): Correct yarn upgrade command for yarn 2.x (#8908)
fix(theme-translations): fix Turkish translation for aria label "Enter key" (#8933)
fix(theme): fix collapsible sidebar behavior when prefers-reduced-motion (#8971)
2023-05-15 15:41:07 +02:00
..
src feat(live-codeblock): add support for noInline to interactive code blocks (#7514) 2022-06-02 10:34:20 +02:00
.npmignore misc: make copyUntypedFiles work for watch mode (#7445) 2022-05-18 19:18:32 +08:00
README.md docs(v2): Add READMEs to v2 packages (#4034) 2021-01-14 17:16:26 +01:00
package.json chore: backport retro compatible commits for the Docusaurus v2.4.1 release (#8979) 2023-05-15 15:41:07 +02:00
tsconfig.client.json refactor: make each tsconfig explicitly declare module and include/exclude (#7443) 2022-05-18 12:48:28 +08:00
tsconfig.json chore: upgrade to TS 4.7, compile with NodeNext (#7586) 2022-06-15 19:15:11 +02:00

Docusaurus Live Codeblock

You can create live code editors with a code block live meta string.

Install

npm i @docusaurus/theme-live-codeblock # or yarn add @docusaurus/theme-live-codeblock

Modify your docusaurus.config.js

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

Example:

```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>
  );
}
```