Skip to content

Commit 7ed4467

Browse files
authored
Update Docusaurus to latest (#407)
1 parent 93ef0fb commit 7ed4467

File tree

16 files changed

+4045
-5684
lines changed

16 files changed

+4045
-5684
lines changed

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v16.15.1

content/languages/agda/agda.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

content/languages/lean/lean.md

Lines changed: 0 additions & 16 deletions
This file was deleted.

content/languages/rust/rust.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

docusaurus.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ module.exports = {
1313
projectName: "docs",
1414
// https://docusaurus.io/docs/next/api/themes/configuration
1515
themeConfig: {
16+
docs: {
17+
sidebar: {
18+
hideable: true,
19+
},
20+
},
1621
colorMode: {
1722
defaultMode: "dark",
1823
},
@@ -47,7 +52,6 @@ module.exports = {
4752
},
4853
],
4954
},
50-
hideableSidebar: true,
5155
footer: {
5256
links: [],
5357
copyright: `Copyright © ${new Date().getFullYear()} Codewars`,

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"write-heading-ids": "docusaurus write-heading-ids"
1717
},
1818
"dependencies": {
19-
"@docusaurus/core": "2.0.0-beta.1",
20-
"@docusaurus/preset-classic": "2.0.0-beta.1",
19+
"@docusaurus/core": "^2.0.0-beta.21",
20+
"@docusaurus/preset-classic": "^2.0.0-beta.21",
2121
"@mdx-js/react": "^1.6.21",
2222
"@tabler/icons": "^1.40.2",
2323
"clsx": "^1.1.1",

sidebars.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ module.exports = {
106106
{
107107
type: "category",
108108
label: "Agda",
109-
items: ["languages/agda/index", "languages/agda/agda"],
109+
items: ["languages/agda/index"],
110110
},
111111
{
112112
type: "category",
@@ -168,7 +168,10 @@ module.exports = {
168168
{
169169
type: "category",
170170
label: "Igloo",
171-
items: ["languages/cpp/igloo/index", "languages/cpp/igloo/stringizers"],
171+
items: [
172+
"languages/cpp/igloo/index",
173+
"languages/cpp/igloo/stringizers",
174+
],
172175
},
173176
],
174177
},
@@ -210,7 +213,11 @@ module.exports = {
210213
{
211214
type: "category",
212215
label: "Factor",
213-
items: ["languages/factor/index", "languages/factor/authoring", "languages/factor/testest"],
216+
items: [
217+
"languages/factor/index",
218+
"languages/factor/authoring",
219+
"languages/factor/testest",
220+
],
214221
},
215222
{
216223
type: "category",
@@ -288,12 +295,16 @@ module.exports = {
288295
{
289296
type: "category",
290297
label: "Lambda Calculus",
291-
items: ["languages/lambdacalc/index", "languages/lambdacalc/authoring", "languages/lambdacalc/lc-test"],
298+
items: [
299+
"languages/lambdacalc/index",
300+
"languages/lambdacalc/authoring",
301+
"languages/lambdacalc/lc-test",
302+
],
292303
},
293304
{
294305
type: "category",
295306
label: "Lean",
296-
items: ["languages/lean/index", "languages/lean/lean"],
307+
items: ["languages/lean/index"],
297308
},
298309
{
299310
type: "category",
@@ -391,7 +402,7 @@ module.exports = {
391402
{
392403
type: "category",
393404
label: "Rust",
394-
items: ["languages/rust/index", "languages/rust/rust"],
405+
items: ["languages/rust/index"],
395406
},
396407
{
397408
type: "category",

src/remark/shiki/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ const remapLanguageId = (id) => {
8484
};
8585

8686
// Use shiki for syntax highlighting.
87-
// Also store Base64 encoded code in HTML, so we can use that to implement copy button.
8887
// TODO Decoration. Like Docusaurus builtin, or https://github.com/shikijs/shiki/issues/5
8988
// or https://github.com/andrewbranch/gatsby-remark-vscode#line-highlighting
9089
const createHighlighter = ({ theme = "nord" } = {}) => {
@@ -159,8 +158,7 @@ const createHighlighter = ({ theme = "nord" } = {}) => {
159158
}
160159
}
161160

162-
const b64 = Buffer.from(code).toString("base64");
163-
let html = `<pre style="background-color: ${bg}" codedata="${b64}">`;
161+
let html = `<pre class="${theme}" style="background-color: ${bg}">`;
164162
html += `<code class="language-${lang}">`;
165163
for (const line of tokenLines) {
166164
html += `<span>`;

src/theme/CodeBlock/index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/// <reference types="react" />
2+
import type { Props } from '@theme/CodeBlock';
3+
export default function CodeBlock({ children: rawChildren, ...props }: Props): JSX.Element;
Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
1-
import React, { useState } from "react";
21
import copy from "copy-text-to-clipboard";
2+
import React, { useRef, useState } from "react";
33

4-
const CodeBlockWithCopy = ({ codedata, ...props }) => {
4+
const CodeBlock = ({ ...props }) => {
5+
const pre = useRef(null);
56
const [showCopied, setShowCopied] = useState(false);
67
const handleCopyCode = () => {
7-
copy(atob(codedata));
8-
setShowCopied(true);
9-
setTimeout(() => setShowCopied(false), 1500);
8+
if (pre.current) {
9+
copy(
10+
Array.from(pre.current.querySelectorAll("code"))
11+
.map((el) => el.textContent)
12+
.join("\n")
13+
);
14+
setShowCopied(true);
15+
setTimeout(() => setShowCopied(false), 1500);
16+
}
1017
};
1118

1219
return (
1320
<div className="relative group">
14-
<pre {...props}></pre>
21+
<pre ref={pre} {...props}></pre>
1522
<button
1623
type="button"
1724
aria-label={"Copy code to clipboard"}
@@ -24,4 +31,4 @@ const CodeBlockWithCopy = ({ codedata, ...props }) => {
2431
);
2532
};
2633

27-
export default CodeBlockWithCopy;
34+
export default CodeBlock;

src/theme/MDXComponents/Code.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/// <reference types="react" />
2+
import type { Props } from '@theme/MDXComponents/Code';
3+
export default function MDXCode(props: Props): JSX.Element;

src/theme/MDXComponents/Code.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import React from "react";
2+
export default function MDXCode(props) {
3+
return <code {...props} />;
4+
}

src/theme/MDXComponents/Pre.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/// <reference types="react" />
2+
import type { Props } from '@theme/MDXComponents/Pre';
3+
export default function MDXPre(props: Props): JSX.Element;

src/theme/MDXComponents/Pre.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import React from "react";
2+
import CodeBlock from "@theme/CodeBlock";
3+
export default function MDXPre(props) {
4+
return <CodeBlock {...props} />;
5+
}

src/theme/MDXComponents/index.jsx

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)