This MDX file
import { MyComponent } from "my-component"
<MyComponent foo={[1, 2, 3]} />Generates this mdxJsxFlowElement node in the MDAST:
| curl -L https://go.microsoft.com/fwlink/?LinkID=620884 > /tmp/vscode.zip | |
| unzip -qq /tmp/vscode.zip -d /tmp | |
| sudo cp -r /tmp/VSCode-linux-x64 /opt/vscode | |
| sudo ln -s /opt/vscode/code /usr/local/bin/vscode | |
| sudo rm -rf /tmp/VSCode-linux-x64 | |
| sudo rm -f /tmp/vscode.zip | |
| sudo touch /usr/share/applications/vscode.desktop | |
| sudo chmod 777 /usr/share/applications/vscode.desktop | |
| sudo echo -e "[Desktop Entry]\nName=VSCode\nComment=Visual Studio Code\nExec=/opt/vscode/code\nIcon=/opt/vscode/resources/app/resources/linux/code.png\nType=Application\nVersion=1.0\nTerminal=false\nCategories=Development" > /usr/share/applications/vscode.desktop | |
| sudo chmod 644 /usr/share/applications/vscode.desktop |
| const MINUTE = 60, | |
| HOUR = MINUTE * 60, | |
| DAY = HOUR * 24, | |
| YEAR = DAY * 365; | |
| function getTimeAgo(date) { | |
| const secondsAgo = Math.round((+new Date() - date) / 1000); | |
| if (secondsAgo < MINUTE) { | |
| return secondsAgo + "s"; |
| import fs from "node:fs" | |
| import { jsx, toJs } from "estree-util-to-js" | |
| function recmaPlugin() { | |
| return (tree) => { | |
| const result = toJs(tree, { handlers: jsx }) | |
| fs.writeFileSync("recma.jsx", result.value) | |
| } | |
| } |
| function Code() { | |
| const ref = React.useRef() | |
| React.useEffect(() => { | |
| const handler = e => { | |
| const selected = document.getSelection().toString().trim() | |
| ref.current.querySelectorAll("span:not(:has(*))").forEach(element => { | |
| if (element.textContent === selected) { | |
| element.classList.add("selected") | |
| } else { | |
| element.classList.remove("selected") |
| function Code() { | |
| const ref = React.useRef() | |
| React.useEffect(() => { | |
| const handler = e => { | |
| const selected = document.getSelection().toString().trim() | |
| ref.current.querySelectorAll("span:not(:has(*))").forEach(element => { | |
| if (element.textContent === selected) { | |
| element.classList.add("selected") | |
| } else { | |
| element.classList.remove("selected") |
| import { bundleMDX } from "mdx-bundler"; | |
| import { getMDXComponent } from "mdx-bundler/client"; | |
| import React from "react"; | |
| export async function getServerSideProps() { | |
| const mdxSource = ` | |
| # Hello | |
| ~~~js | |
| console.log(1); | |
| ~~~`; |
This MDX file
import { MyComponent } from "my-component"
<MyComponent foo={[1, 2, 3]} />Generates this mdxJsxFlowElement node in the MDAST:
| { | |
| "stuff": "...", | |
| "scripts": { | |
| "postinstall": "run-p install:api install:web", | |
| "install:api": "cd api && npm install", | |
| "install:web": "cd web && npm install", | |
| "start": "run-p start:api start:web", | |
| "start:api": "npm run start --prefix api", | |
| "start:web": "npm run start --prefix web", |
| function slowmo(rate = 10) { | |
| window._raf = window.requestAnimationFrame | |
| window.requestAnimationFrame = f => window._raf(t => f(t/rate)) | |
| Date._now = Date.now | |
| Date.now = () => Date._now() / rate | |
| performance._now = performance.now | |
| performance.now = () => performance._now()/rate | |
| } | |
| slowmo() |