1
0
mirror of https://github.com/actix/actix-website synced 2025-06-30 08:44:27 +02:00

prettier js/html

This commit is contained in:
Rob Ede
2023-11-01 15:32:44 +00:00
parent 0d0e7f4433
commit ee701e0e23
10 changed files with 122 additions and 117 deletions

View File

@ -1,21 +1,21 @@
import React, { useState, useEffect } from 'react';
import RenderCodeBlock from '@theme/CodeBlock';
import React, { useState, useEffect } from "react";
import RenderCodeBlock from "@theme/CodeBlock";
const CodeBlock = ({ example, file, section, language }) => {
const [code, setCode] = useState('');
const [code, setCode] = useState("");
useEffect(() => {
let isMounted = true;
const path =
file === 'manifest' ? 'Cargo.toml' : `src/${file ?? 'main.rs'}`;
file === "manifest" ? "Cargo.toml" : `src/${file ?? "main.rs"}`;
import(`!!raw-loader!@site/examples/${example}/${path}`)
.then((source) => {
source = source.default.match(
new RegExp(
`(?:\/\/|#) <${section}>\n([\\s\\S]*)(?:\/\/|#) <\/${section}>`
)
`(?:\/\/|#) <${section}>\n([\\s\\S]*)(?:\/\/|#) <\/${section}>`,
),
)[1];
if (isMounted) setCode(source);
@ -28,7 +28,7 @@ const CodeBlock = ({ example, file, section, language }) => {
}, []);
return (
<RenderCodeBlock className={`language-${language ?? 'rust'}`}>
<RenderCodeBlock className={`language-${language ?? "rust"}`}>
{code}
</RenderCodeBlock>
);