@hackersheet/next-document-content-components 0.1.0-alpha.7 → 0.1.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/code-block/code-block-copy-button.js +1 -1
- package/dist/cjs/components/code-block/shiki.js +1 -1
- package/dist/cjs/components/gist/gist.js +5 -4
- package/dist/esm/components/code-block/code-block-copy-button.mjs +1 -1
- package/dist/esm/components/code-block/shiki.mjs +1 -1
- package/dist/esm/components/gist/gist.mjs +5 -4
- package/package.json +4 -4
|
@@ -43,5 +43,5 @@ function CodeBlockCopyButton({ code }) {
|
|
|
43
43
|
setTimeout(() => setCopied(false), 1e3);
|
|
44
44
|
});
|
|
45
45
|
};
|
|
46
|
-
return /* @__PURE__ */ import_react.default.createElement("button", { onClick: handleClick }, copied ? /* @__PURE__ */ import_react.default.createElement(import_hi2.HiCheck, { size: 18 }) : /* @__PURE__ */ import_react.default.createElement(import_hi2.HiOutlineClipboardDocumentList, { size: 18 }));
|
|
46
|
+
return /* @__PURE__ */ import_react.default.createElement("button", { onClick: handleClick, "aria-label": "Copy code to clipboard" }, copied ? /* @__PURE__ */ import_react.default.createElement(import_hi2.HiCheck, { size: 18 }) : /* @__PURE__ */ import_react.default.createElement(import_hi2.HiOutlineClipboardDocumentList, { size: 18 }));
|
|
47
47
|
}
|
|
@@ -30,7 +30,7 @@ async function highlighteCode(code, language) {
|
|
|
30
30
|
if (shikiLang === void 0 && language !== "text") {
|
|
31
31
|
return null;
|
|
32
32
|
}
|
|
33
|
-
const html = highlighter.codeToHtml(code, {
|
|
33
|
+
const html = highlighter.codeToHtml(code.trim(), {
|
|
34
34
|
lang: shikiLang || "text",
|
|
35
35
|
themes: {
|
|
36
36
|
light: "github-light",
|
|
@@ -31,18 +31,19 @@ __export(gist_exports, {
|
|
|
31
31
|
default: () => Gist
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(gist_exports);
|
|
34
|
+
var import_script = __toESM(require("next/script"));
|
|
34
35
|
var import_react = __toESM(require("react"));
|
|
35
36
|
async function Gist({ gistId, username, filename }) {
|
|
36
|
-
const
|
|
37
|
+
const gistUrl = (() => {
|
|
37
38
|
const base = `https://gist.github.com/${username}/${gistId}.json`;
|
|
38
39
|
if (filename) {
|
|
39
40
|
return base + `?file=${filename}`;
|
|
40
41
|
}
|
|
41
42
|
return base;
|
|
42
43
|
})();
|
|
43
|
-
const result = await fetch(
|
|
44
|
+
const result = await fetch(gistUrl);
|
|
44
45
|
const json = await result.json();
|
|
45
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
46
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
|
|
46
47
|
"div",
|
|
47
48
|
{
|
|
48
49
|
className: "gist-block",
|
|
@@ -50,5 +51,5 @@ async function Gist({ gistId, username, filename }) {
|
|
|
50
51
|
__html: json.div
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
|
-
);
|
|
54
|
+
), /* @__PURE__ */ import_react.default.createElement(import_script.default, { stylesheets: [json.stylesheet] }));
|
|
54
55
|
}
|
|
@@ -10,7 +10,7 @@ function CodeBlockCopyButton({ code }) {
|
|
|
10
10
|
setTimeout(() => setCopied(false), 1e3);
|
|
11
11
|
});
|
|
12
12
|
};
|
|
13
|
-
return /* @__PURE__ */ React.createElement("button", { onClick: handleClick }, copied ? /* @__PURE__ */ React.createElement(HiCheck, { size: 18 }) : /* @__PURE__ */ React.createElement(HiOutlineClipboardDocumentList, { size: 18 }));
|
|
13
|
+
return /* @__PURE__ */ React.createElement("button", { onClick: handleClick, "aria-label": "Copy code to clipboard" }, copied ? /* @__PURE__ */ React.createElement(HiCheck, { size: 18 }) : /* @__PURE__ */ React.createElement(HiOutlineClipboardDocumentList, { size: 18 }));
|
|
14
14
|
}
|
|
15
15
|
export {
|
|
16
16
|
CodeBlockCopyButton as default
|
|
@@ -12,7 +12,7 @@ async function highlighteCode(code, language) {
|
|
|
12
12
|
if (shikiLang === void 0 && language !== "text") {
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
15
|
-
const html = highlighter.codeToHtml(code, {
|
|
15
|
+
const html = highlighter.codeToHtml(code.trim(), {
|
|
16
16
|
lang: shikiLang || "text",
|
|
17
17
|
themes: {
|
|
18
18
|
light: "github-light",
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
import Script from "next/script";
|
|
1
2
|
import React from "react";
|
|
2
3
|
async function Gist({ gistId, username, filename }) {
|
|
3
|
-
const
|
|
4
|
+
const gistUrl = (() => {
|
|
4
5
|
const base = `https://gist.github.com/${username}/${gistId}.json`;
|
|
5
6
|
if (filename) {
|
|
6
7
|
return base + `?file=${filename}`;
|
|
7
8
|
}
|
|
8
9
|
return base;
|
|
9
10
|
})();
|
|
10
|
-
const result = await fetch(
|
|
11
|
+
const result = await fetch(gistUrl);
|
|
11
12
|
const json = await result.json();
|
|
12
|
-
return /* @__PURE__ */ React.createElement(
|
|
13
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
13
14
|
"div",
|
|
14
15
|
{
|
|
15
16
|
className: "gist-block",
|
|
@@ -17,7 +18,7 @@ async function Gist({ gistId, username, filename }) {
|
|
|
17
18
|
__html: json.div
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
|
-
);
|
|
21
|
+
), /* @__PURE__ */ React.createElement(Script, { stylesheets: [json.stylesheet] }));
|
|
21
22
|
}
|
|
22
23
|
export {
|
|
23
24
|
Gist as default
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hackersheet/next-document-content-components",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.9",
|
|
4
4
|
"description": "Hacker Sheet document content components for Next.js",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"repository": {
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
"dist"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@hackersheet/core": "alpha",
|
|
28
|
-
"@hackersheet/react-document-content": "alpha",
|
|
29
27
|
"@next/third-parties": "^14.2.5",
|
|
30
28
|
"@shikijs/transformers": "^1.10.3",
|
|
31
29
|
"mermaid": "^10.9.1",
|
|
32
30
|
"next-themes": "^0.3.0",
|
|
33
31
|
"react-icons": "^5.2.1",
|
|
34
32
|
"react-tweet": "^3.2.1",
|
|
35
|
-
"shiki": "^1.10.3"
|
|
33
|
+
"shiki": "^1.10.3",
|
|
34
|
+
"@hackersheet/core": "0.1.0-alpha.5",
|
|
35
|
+
"@hackersheet/react-document-content": "0.1.0-alpha.9"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/react": "^18.0.0",
|