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:
@ -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>
|
||||
);
|
||||
|
Reference in New Issue
Block a user