Skip to content

Commit 33e874e

Browse files
committed
feat: add DocsPage component and integrate rehype-raw for markdown processing
1 parent 145c683 commit 33e874e

File tree

5 files changed

+123
-16
lines changed

5 files changed

+123
-16
lines changed

packages/shared/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"r18gs": "^3.0.1",
5151
"react-live": "^4.1.8",
5252
"react18-loaders": "workspace:*",
53+
"rehype-raw": "^7.0.0",
5354
"typingfx": "^1.1.1"
5455
}
5556
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.docs {
2-
/* create your container styles here */
2+
max-width: 800px;
3+
margin: auto;
34
}

packages/shared/src/client/docs/docs.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import readme from "../../../../../README.md?raw"
44
import { Md } from "@m2d/react-markdown";
55
import { toDocx } from "mdast2docx";
66
import { AstArrayElement } from "@m2d/react-markdown/utils";
7+
import rehypeRaw from "rehype-raw";
8+
import rebrandingConfig from "@repo/scripts/rebrand.config.json";
79

10+
const { packageName } = rebrandingConfig;
811
export interface DocsProps extends HTMLProps<HTMLDivElement> {
912
children?: ReactNode;
1013
}
@@ -22,19 +25,20 @@ export const Docs = (props: DocsProps) => {
2225
const url = URL.createObjectURL(docxBlob as Blob);
2326
const a = document.createElement("a");
2427
a.href = url;
25-
a.download = "document.docx";
28+
a.download = `${packageName}.docx`;
2629
document.body.appendChild(a);
2730
a.click();
2831
document.body.removeChild(a);
2932
URL.revokeObjectURL(url);
30-
}).catch(() => {
33+
}).catch((err) => {
34+
console.error(err)
3135
alert("Something went wrong!")
3236
});
3337
} else {
3438
alert("Something went wrong!")
3539
}
3640
}}>Download as Docx</button>
37-
<Md astRef={astRef}>{readme}</Md>
41+
<Md astRef={astRef} rehypePlugins={[rehypeRaw]}>{readme}</Md>
3842
</div>
3943
);
4044
}

pnpm-lock.yaml

Lines changed: 113 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)