mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-31 13:42:59 +00:00 
			
		
		
		
	Some web tooling changes
- Switch to tsx from ts-node, fixing issues on Node 20 - Update rehype
This commit is contained in:
		| @@ -4,7 +4,7 @@ | ||||
|  | ||||
| import type { FunctionComponent } from "react"; | ||||
| import { createElement as h } from "react"; | ||||
| import useExport from "./WithExport.js"; | ||||
| import useExport from "./WithExport"; | ||||
|  | ||||
| const Item: FunctionComponent<{ item: string }> = ({ item }) => { | ||||
|     const data = useExport(); | ||||
|   | ||||
| @@ -13,38 +13,38 @@ | ||||
| import * as fs from "fs/promises"; | ||||
| import { glob } from "glob"; | ||||
| import * as path from "path"; | ||||
| import { createElement, createElement as h, Fragment } from 'react'; | ||||
| import { createElement as h } from 'react'; | ||||
| import runtime from 'react/jsx-runtime'; | ||||
| import { renderToStaticMarkup } from "react-dom/server"; | ||||
| import rehypeHighlight from "rehype-highlight"; | ||||
| import rehypeParse from 'rehype-parse'; | ||||
| import rehypeReact from 'rehype-react'; | ||||
| import rehypeReact, { type Options as ReactOptions } from 'rehype-react'; | ||||
| import { unified } from 'unified'; | ||||
| // Our components | ||||
| import Recipe from "./components/Recipe.js"; | ||||
| import { noChildren } from "./components/support.js"; | ||||
| import { type DataExport, WithExport } from "./components/WithExport.js"; | ||||
| import Recipe from "./components/Recipe"; | ||||
| import { noChildren } from "./components/support"; | ||||
| import { type DataExport, WithExport } from "./components/WithExport"; | ||||
|  | ||||
| (async () => { | ||||
|     const base = "build/illuaminate"; | ||||
|  | ||||
|     const reactOptions: ReactOptions = { | ||||
|         ...(runtime as ReactOptions), | ||||
|         components: { | ||||
|             ['mc-recipe']: noChildren(Recipe), | ||||
|             ['mcrecipe']: noChildren(Recipe), | ||||
|             // Wrap example snippets in a <div class="lua-example">...</div>, so we can inject a | ||||
|             // Run button into them. | ||||
|             ['pre']: (args: JSX.IntrinsicElements["pre"] & { "data-lua-kind"?: undefined }) => { | ||||
|                 const element = <pre {...args} />; | ||||
|                 return args["data-lua-kind"] ? <div className="lua-example">{element}</div> : element | ||||
|             } | ||||
|         } as any | ||||
|     }; | ||||
|     const processor = unified() | ||||
|         .use(rehypeParse, { emitParseErrors: true }) | ||||
|         .use(rehypeHighlight, { prefix: "" }) | ||||
|         .use(rehypeReact, { | ||||
|             createElement, | ||||
|             Fragment, | ||||
|             passNode: false, | ||||
|             components: { | ||||
|                 ['mc-recipe']: noChildren(Recipe), | ||||
|                 ['mcrecipe']: noChildren(Recipe), | ||||
|                 // Wrap example snippets in a <div class="lua-example">...</div>, so we can inject a | ||||
|                 // Run button into them. | ||||
|                 ['pre']: (args: JSX.IntrinsicElements["pre"] & { "data-lua-kind"?: undefined }) => { | ||||
|                     const element = <pre {...args} />; | ||||
|                     return args["data-lua-kind"] ? <div className="lua-example">{element}</div> : element | ||||
|                 } | ||||
|             } as any | ||||
|         }); | ||||
|         .use(rehypeReact, reactOptions); | ||||
|  | ||||
|     const dataExport = JSON.parse(await fs.readFile("src/export/index.json", "utf-8")) as DataExport; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jonathan Coates
					Jonathan Coates