mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-15 15:55:56 +02:00
Co-authored-by: Joshua Chen <sidachen2003@gmail.com> Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com> Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com> Co-authored-by: Ben Gubler <nebrelbug@gmail.com> Co-authored-by: Davide Donadio <davide.donadio@it.clara.net> Co-authored-by: Petter Drønnen <36735557+dr0nn1@users.noreply.github.com> Co-authored-by: Moritz Stückler <moritz@bitbetter.de> Co-authored-by: Mysterious_Dev <40738104+Mysterious-Dev@users.noreply.github.com> Co-authored-by: TrueQAP <32407751+trueqap@users.noreply.github.com> Co-authored-by: Kagan <34136752+kagankan@users.noreply.github.com> Co-authored-by: Dewansh Thakur <71703033+dewanshDT@users.noreply.github.com> Co-authored-by: Armano <armano2@users.noreply.github.com> Co-authored-by: Anas <60762285+Anasqx@users.noreply.github.com> Co-authored-by: Tanner Dolby <tannercdolby@gmail.com> Co-authored-by: Davide Donadio <davide.donadio94@gmail.com> Co-authored-by: biplavmz <68702055+biplavmz@users.noreply.github.com> Co-authored-by: Vishruta Patil <72292532+Vishruta-Patil@users.noreply.github.com> fix(theme-classic): fix tab focus bug in dropdown (#8697) (#8699) fix(theme): improve color toggle when using dark navbar (#8615) fix(theme-translations): fix wrong arabic words (tip/next) (#8744) fix(core): baseUrl error banner link anchor case (#8746) fix(search): search page should react to querystring changes + cleanup/refactor (#8757) fix(theme): allow tabs children to be falsy (#8801) fix(theme): codeblock buttons should be kept on the right when using RTL locale (#8803) |
||
---|---|---|
.. | ||
src | ||
.npmignore | ||
package.json | ||
README.md | ||
tsconfig.client.json | ||
tsconfig.json |
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>
);
}
```